[ 
https://issues.apache.org/jira/browse/HTTPASYNC-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16731731#comment-16731731
 ] 

Eric Lan commented on HTTPASYNC-146:
------------------------------------

Hi [~olegk], Thanks your quickly response. The description did not said the 
import information, there is a delay between sending the response and closing 
the connection. My case is
# send the 301 response "HTTP/1.1 301 Moved\r\nLocation: /redirect\r\n", no 
content-length, do close connection.
# wait a moment.
# closing the connection.

That means when first to parse the response, the connection is NOT closed. but 
after parse the response, the connection is closed, the case will failed
{code:java}
@Test
    public void testHTTPASYNC_146() throws Exception {
        final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, 
Consts.ASCII);

        final NHttpMessageParser<HttpResponse> messageParser = new 
DefaultHttpResponseParser(inbuf);
        final ReadableByteChannel channel = Channels.newChannel("HTTP/1.1 301 
Moved\r\nLocation: /redirect\r\n");
        messageParser.fillBuffer(channel);
        final HttpResponse response = messageParser.parse();
        messageParser.fillBuffer(channel);
        final HttpResponse response2 = messageParser.parse();
        Assert.assertThat(response == null ? response2 : response, 
CoreMatchers.notNullValue());
        Assert.assertThat(response.getStatusLine().getStatusCode(), 
CoreMatchers.equalTo(301));
        final Header[] headers = response.getAllHeaders();
        Assert.assertThat(headers.length, CoreMatchers.equalTo(1));
        Assert.assertThat(headers[0].getName(), 
CoreMatchers.equalTo("Location"));
    }
{code}


> 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]

Reply via email to