Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java version of curl request filter #178

Merged
merged 14 commits into from
Jun 14, 2018
Merged

Java version of curl request filter #178

merged 14 commits into from
Jun 14, 2018

Conversation

marcospereira
Copy link
Member

Purpose

This adds a Java version of curl-logger request filter that is present in the Scala APIs.

To do that, a number of changes we made in the Java version of StandaloneWSRequest so that we can access request information and create the curl command.

Also, tests were added to both Java and Scala version of the request filter.

class AhcWSRequestFilterSpec(implicit executionEnv: ExecutionEnv) extends Specification with AfterAll with FutureMatchers {
val testServerPort = 49134

sequential
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to use sequential anymore. :-)

@@ -76,6 +75,7 @@ trait CurlFormat {
// XXX Need to escape any quotes within the body of the string.
b.append(s" --data '${quote(bodyString)}'")
b.append(" \\\n")
case EmptyBody => // do nothing
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just do nothing instead of throwing an exception.

| --request GET \\
| --header "Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=" \\
| --header 'My-Header: My-Header-Value' \\
| --header 'Content-Type: text/plain' \\
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #179.

build.sbt Outdated
lazy val mimaSettings = mimaDefaultSettings ++ Seq(
mimaBinaryIssueFilters ++= Seq(
// Added to have better parity between Java and Scala APIs
ProblemFilters.exclude[ReversedMissingMethodProblem]("play.libs.ws.StandaloneWSRequest.getBody"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the justification for the breaking change is that we don't support custom implementations of the WS API? i.e. you have to use our provided AhcWSRequest and can't write your own.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gmethvin this was a change to the interface (StandaloneWSRequest).

In this case, the problem is that Java API was missing some methods/features that are already present in the Scala API. Adding them breaks compatibility in both interface and implementation.

I don't see what would prevent custom implementations of the WS API.

@richdougherty
Copy link
Member

This looks OK to me. Are we going to bump versions due to bin compatibility changes or are these changes OK?

@marcospereira
Copy link
Member Author

@richdougherty we can backport part of this, without breaking compatibility.

But in order to have curl logging support for both Java and Scala, we need some new methods that don't exist without this PR. :-)

@marcospereira
Copy link
Member Author

Rebased against the master branch.

This is ready to be reviewed/merged.

@marcospereira marcospereira mentioned this pull request Aug 28, 2017
@marcospereira
Copy link
Member Author

Fixed conflicts. I think this is ready to be merged.

@AlejandroRivera
Copy link
Contributor

AlejandroRivera commented Jan 26, 2018

@marcospereira: not sure if you find this important for this feature, but you might also want to consider adding the --cookie curl flag to this logger as well... however, you'll notice that there's no getCookie(String) method (just like there was no getMethod() method either).

See #232

@marcospereira marcospereira merged commit 7d186f5 into playframework:master Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants