spring-mvc:chunked responses with status 500 are damaged
See original GitHub issueversion: Spring Boot 2.2.5.RELEASE environment: java: Java™ SE Runtime Environment (build 1.8.0_172-b11) os: mac. os and linux contrainer: tomcat
the bug is related to here I have worked for days to reproduced the problem
https://github.com/spring-cloud/spring-cloud-gateway/issues/1600
when I create a controller and just return ResponseEntity there will be return
curl: (56) Illegal or missing hexadecimal sequence in chunked-encoding
my code
@RequestMapping("api/v1")
@RestController
public class ProxyController {
@GetMapping("/proxy500")
public ResponseEntity<?> proxy500(ProxyExchange<byte[]> proxy) {
MultiValueMap<String, String> multiValueMap = new HttpHeaders();
multiValueMap.put("Transfer-Encoding", Collections.singletonList("chunked"));
multiValueMap.put("Connection", Collections.singletonList("close"));
return new ResponseEntity<>("{", multiValueMap, HttpStatus.INTERNAL_SERVER_ERROR);
}
}
detail
curl http://localhost:8080/api/v1/proxy500 -vvv
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
> GET /api/v1/proxy500 HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 500
< Transfer-Encoding: chunked
< Connection: close
< Content-Type: text/plain;charset=UTF-8
< Date: Sat, 14 Mar 2020 17:13:04 GMT
<
* Illegal or missing hexadecimal sequence in chunked-encoding
* stopped the pause stream!
* Closing connection 0
curl: (56) Illegal or missing hexadecimal sequence in chunked-encoding
reason maybe here , the header info send flush until message send
org.springframework.http.converter.StringHttpMessageConverter#writeInternal
@Override
protected void writeInternal(String str, HttpOutputMessage outputMessage) throws IOException {
HttpHeaders headers = outputMessage.getHeaders();
if (this.writeAcceptCharset && headers.get(HttpHeaders.ACCEPT_CHARSET) == null) {
headers.setAcceptCharset(getAcceptedCharsets());
}
Charset charset = getContentTypeCharset(headers.getContentType());
StreamUtils.copy(str, charset, outputMessage.getBody());
}
this my source code
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (2 by maintainers)
Top Results From Across the Web
gateway-mvc: chunked responses with status 500 are damaged
When using default tomcat servlet container, 500 errors that are produced in the downstream service are not correctly transfered to the client. Actual...
Read more >ERR_INCOMPLETE_CHUNKED...
I faced this ERR_INCOMPLETE_CHUNKED_ENCODING issue specifically with POST requests handled in the context of a proxy: requests were initiated ...
Read more >Error handling in REST and Spring Boot | Nullbeans
In this post, we will discuss how to handle common errors (such as HTTP 404 Not found) and exceptions in your REST API...
Read more >"too many transfer encodings" 502 chunked response errors ...
The error described in this KB occurs if any response from an application has multiple transfer-encoding headers, either directly adding or a ...
Read more >Spring4Shell: Zero-Day Vulnerability in Spring Framework
The vulnerability affects SpringMVC and Spring WebFlux applications ... web application paths in order to trigger an HTTP 500 response, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@rstoyanchev thx, I am will keep working on it
Same problem! I think it should be solved in application framework not in servlet container.