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

Cannot overwrite content-type response header with WebFlux [SPR-17415] #21948

Closed
spring-issuemaster opened this issue Oct 19, 2018 · 2 comments
Closed
Assignees
Milestone

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Oct 19, 2018

Peter Luttrell opened SPR-17415 and commented

I originally reported spring-projects/spring-boot#13635 which Brian Clozel troubleshooted and transferred to #21619 and then resolved. This resolved my original issue when I upgraded to Spring Boot 2.1.0.M4 (Spring 5.1.0.RELEASE).

But when I upgraded to Spring Boot 2.1.0.RC1 (Spring 5.1.1.RELEASE), the issue came back. 

Here is sample output in the original Spring Boot report and the example in #21619 when using 2.1.0.M4/5.1.0.RELEASE:

$ http localhost:8080/binary-test apiKey==bad
HTTP/1.1 403 Forbidden
Content-Length: 36
Content-Type: application/json;charset=UTF-8

{
    "developerMessage": "access denied"
}


$ http localhost:8080/test                   
HTTP/1.1 400 Bad Request
Content-Length: 32
Content-Type: application/json

{
    "field1": "test-error-response"
}

 

And here is exactly the same two calls when I only switch to 2.1.0.RC1/5.1.1.RELEASE:

$ http localhost:8080/binary-test apiKey==bad
HTTP/1.1 406 Not Acceptable
Content-Length: 157
Content-Type: application/json;charset=UTF-8

{
    "error": "Not Acceptable",
    "message": "Could not find acceptable representation",
    "path": "/binary-test",
    "status": 406,
    "timestamp": "2018-10-19T23:33:58.349+0000"
}

$ http localhost:8080/test                   
HTTP/1.1 400 Bad Request
Content-Length: 32
Content-Type: text/plain;charset=UTF-8
Content-Type: application/json


http: error: LookupError: unknown encoding: UTF-8, application/json

 

 


Affects: 5.1.1

Issue Links:

  • #21619 ResponseEntityResultHandler does not overwrite existing response headers
@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Oct 20, 2018

Peter Luttrell commented

Here's a quick project that shows the issue in at least one case. https://github.com/pluttrell/406-bug. I believe that there are more cases that trigger this issue.

I think it's interesting that the unit test with the WebTestClient now passes but the manual calls exhibit the bug. When I originally reported this issue both the same unit test and manual tests exhibited the same problem. And were both fixed with the original fix.

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Oct 22, 2018

Brian Clozel commented

This has been fixed and should be shortly available in Spring Framework and Spring Boot SNAPSHOTs. This has been introduced in #21783 for Reactor Netty and Tomcat. Using Jetty as a server in your sample works as expected.

Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.