-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Multiple header when use ResponseEntity.status(200).header("content-type","xxx") #24481
Comments
I was not able to reproduce this problem and even added a test in #24489 to validate that we follow the proper behavior. |
@geoand Thanks for your work and quick reply. I have try to do the same test for my code and unit test working for me, but i really got the two same header when i after started application. now, my quarkus version is My test code: @Test
public void headerTest(){
given()
.when().get("/hello")
.then()
.statusCode(200)
.header("content-type","application/jsontest")
.header("custom-header","value");
} API method code: @GetMapping("/hello")
public ResponseEntity<BaseResponse> hello(){
return ResponseEntity.status(200).contentType(org.springframework.http.MediaType.valueOf("application/jsontest")).header("custom-header","value").build();
} Call API
|
Thanks, let me check |
I updated the PR to use your latest code and again everything works as expected |
Yes,unit test is working, but request to the really API, it in the wrong side. This is the min reproduce code.
|
Now I see what the confusion is. You are using Thanks |
Thanks for your confirmed, Change |
Add test to make sure ResponseEntity content type takes precedence
Describe the bug
Return multiple header of content-type
Expected behavior
Only one header of
Content-Type
and rewrite it when we use some code like thatResponseEntity.status(200).header("content-type","application/jsonhello").build();
Actual behavior
Multiple header of
Content-Type
How to Reproduce?
Some simple code, use spring web for API.
Run the application and request this API.
oem@lan:~$ curl -X GET http://localhost:8080/hello -I HTTP/1.1 200 OK Content-Type: application/json Content-Type: application/jsonhello content-length: 0
Output of
uname -a
orver
Output of
java -version
GraalVM version (if different from Java)
No response
Quarkus version or git rev
No response
Build tool (ie. output of
mvnw --version
orgradlew --version
)Additional information
The text was updated successfully, but these errors were encountered: