hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Senduran <bsendu...@gmail.com>
Subject Handling 204 Response with Body
Date Fri, 25 Mar 2016 10:59:27 GMT
Hi all,

Some backend responses the '204 No content' status code with body (yes,
clearly spec violation)
In our targetHandler
<https://svn.wso2.org/repos/wso2/carbon/platform/tags/turing-chunk08/dependencies/synapse/2.1.2-wso2v5/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/TargetHandler.java#L200>
we check(isResponseHaveBodyExpected) for some status code (204, 205 and
304) and assumes those will not contain body and continue the rest. Once we
find those status code we call resetInput()
<http://grepcode.com/file/repo1.maven.org/maven2/org.apache.httpcomponents/httpcore-nio/4.2.3/org/apache/http/impl/nio/DefaultNHttpClientConnection.java?av=f#146>.(But
it didn't clear the sessionInputBuffer)

Every thing works fine, unless such spec violation happens. Once the 204
comes with a message body, the sessionInputBuffer is filled with the
content. and no one will consume it. So when the 2nd response comes (using
the same connection) it will use the same session input buffer and will get
a corrupted data. (in this case we are getting protocol violation
exception, since the 1st 204 response's body is prepended to the 2nd
response's status line)

What would be best way to fix this

Thanks
Senduran

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message