[
https://issues.apache.org/jira/browse/HTTPASYNC-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16732565#comment-16732565
]
Eric Lan commented on HTTPASYNC-146:
------------------------------------
Hi [~olegk], Yes, you are right. But
# Finally, the connection is closed. we should get the response after
connection is closed.
# Your original case need to call twice "messageParser.fillBuffer(channel)",
then call "messageParser.parse()" to get the response, but in fact, we should
call once "messageParser.fillBuffer(channel)", then call
"messageParser.parse()" to try to get the response, we don't if we need more
data to parse the response. and it's implemented in
DefaultNHttpClientConnection.java from line 240 to line 246.
{code:java}
do {
bytesRead =
this.responseParser.fillBuffer(this.session.channel());
if (bytesRead > 0) {
this.inTransportMetrics.incrementBytesTransferred(bytesRead);
}
this.response = this.responseParser.parse();
} while (bytesRead > 0 && this.response == null);
{code}
So, when first to parse the response, we get all data but the connection is not
closed. and when second to parse the response, we read nothing and the
connection is closed, it means the response is finished, it should return the
response rather than null.
> Can't handle the response for the remote server send response and close
> connection
> ----------------------------------------------------------------------------------
>
> Key: HTTPASYNC-146
> URL: https://issues.apache.org/jira/browse/HTTPASYNC-146
> Project: HttpComponents HttpAsyncClient
> Issue Type: Bug
> Affects Versions: 4.1.3
> Reporter: Eric Lan
> Priority: Major
>
> When the server return response, such as HTTP 301 for redirect, and close
> the connection.
> The AbstractMessageParser#parse will return null.
> {code}
> HTTP/1.1 301 Moved\r\nLocation: /redirect\r\n
> {code}
> *Notice: there is no last \r\n to mark there is no more headers but the
> server close the connection*
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]