mirror of
https://github.com/jlengrand/quarkus.git
synced 2026-03-10 08:41:22 +00:00
Fix header conversion when converting from Spring ResponseEntity to JAX-RS Response
This commit is contained in:
committed by
Guillaume Smet
parent
224bf0e024
commit
4fbbeba236
@@ -22,7 +22,7 @@ public class ResponseEntityConverter {
|
||||
private static Headers<Object> toHeaders(HttpHeaders springHeaders) {
|
||||
Headers<Object> jaxRsHeaders = new Headers<>();
|
||||
for (Map.Entry<String, List<String>> entry : springHeaders.entrySet()) {
|
||||
jaxRsHeaders.addAll(entry.getKey(), entry.getValue());
|
||||
jaxRsHeaders.addAll(entry.getKey(), entry.getValue().toArray(new Object[0]));
|
||||
}
|
||||
return jaxRsHeaders;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class CustomAdvice {
|
||||
@ExceptionHandler(IllegalStateException.class)
|
||||
public ResponseEntity<Error> handleIllegalStateException(IllegalStateException e,
|
||||
HttpServletRequest request, HttpServletResponse response) {
|
||||
return ResponseEntity.status(HttpStatus.PAYMENT_REQUIRED)
|
||||
return ResponseEntity.status(HttpStatus.PAYMENT_REQUIRED).header("custom-header", "custom-value")
|
||||
.body(new Error(request.getRequestURI() + ":" + e.getMessage()));
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,8 @@ public class SpringControllerTest {
|
||||
RestAssured.when().get("/exception/responseEntity").then()
|
||||
.contentType("application/json")
|
||||
.body(containsString("bad state"), containsString("responseEntity"))
|
||||
.statusCode(402);
|
||||
.statusCode(402)
|
||||
.header("custom-header", "custom-value");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user