Soap Context Mapper copies transfer-encoding header to output
hmaa Oct 23, 2017 1:32 PMHi all.
I'm dealing with a possible bug in Soap Context mapper when the client is using HTTP Chunking.
Please see the attached sample project.
Steps to reproduce:
-Deploy the provided sample in Jboss EAP 6.4 with fuse 6.3
-Make a request to the http://localhost:8080/service/service with chunking disabled - Everything ok
-Make a request to the http://localhost:8080/service/service with chunking enabled (transfer-encoding:chunked header and no content length) - Timeout Error
-Add the CustomContextMapper as a custom composer class of the service
-Make a request to the http://localhost:8080/service/service with chunking enabled (transfer-encoding:chunked header and no content length) - Everything ok
-Make a request to the http://localhost:8080/service/service with chunking disabled - Everything ok
Error description:
When the client uses HTTP chunking it will send the "transfer-encoding:chunked" header instead of the content-length header.
While Composing the response message the switchyard class org.switchyard.component.soap.composer.SOAPContextMapper copies the headers from the request to the response.
In the mapTo(Context context, SOAPBindingData target) function we can see that it checks the list HTTP_HEADERS_EXCLUDED to ignore some headers that cannot be copied. For example the "content-type" and "content-length".
Since the transfer-encoding header is not included in HTTP_HEADERS_EXCLUDED list it is also copied to the response.
So the client will receive the "transfer-encoding" header and the "content-length" header simultaneously. Since receiving both headers is not an expected behavior the client can have problems while reading the response. For example CXF keeps waiting indefinitely for the last chunk until timeouts.
For a temporary fix I've added a custom context mapper(com.example.switchyard.switchyard_example.impl.CustomContextMapper) that removes the transfer-encoding header after the execution of the SOAPContextMapper mapTo.
Fix
Add "transfer-encoding" to the HTTP_HEADERS_EXCLUDED list.
Github fork with the correction: GitHub - hugo-ma-alves/switchyard: Aggregated SwitchYard repository
If it is correct I can create a pull request.
Regards
Hugo Alves
-
sample_chunking.zip 8.6 KB