2

I'm trying to fix an issue re. http response-header: Transfer-Encoding: chunked

We have a CXF-SOAP webservice in spring-boot + embedded-tomcat.

The SOAP-responses get a Content-Length header, and no Transfer-Encoding .... which is normal, I guess?

Unfortunately, we have some legacy client-hacks, that only seem to work with Transfer-Encoding: chunked and no Content-Length.

Is there a way to force the server-app to respond with Transfer-Encoding: chunked ?

What exactly determines which response-format is generated?

Is it somehow configurable?

Rop
  • 3,359
  • 3
  • 38
  • 59

2 Answers2

5

By setting the BufferSize on response.

response.setBufferSize() sets the Content-Length header of the response size. Once the response size goes beyond the bufferSize it would fallback to Transfer-Encoding: Chunked. The buffer size should be set to an appropriate value. Setting it to a higher value would buffer all of the response in memory before flushing it. So the value should be set to an optimistic size.

By default Tomcat buffer size is set to 8K

Other option : You can add a response filter for you service and in that set header you want.

gladiator
  • 1,249
  • 8
  • 23
3

The server app will respond however you want it to respond, depending on the request http header.

If request http header contains:

Accept-Encoding: chunked

and only chunked, the server app will respond with a header and content Transfer-Encoding: chunked.

So if one can not make a correct http request indicating the client capabilities, one can add a reverse proxy, modifying the request by changing or adding the Accept-Encoding: chunked header.

Danny
  • 1,603
  • 1
  • 15
  • 25