hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francesco Lazzarino <f...@ufl.edu>
Subject Re: handle response when connection is closed.
Date Thu, 01 May 2008 14:31:43 GMT

On Apr 30, 2008, at 4:50 AM, Oleg Kalnichevski wrote:

> On Tue, 2008-04-29 at 16:22 -0400, Francesco Lazzarino wrote:
>> # scenario:
>> PUTting a large file to a URL.
>> server reads Content-Length header and determines the file is to  
>> large.
>> server sends a 413 response.
>> server closes connection.
>>
>> # my problem:
>> Since it is a large file the entity is not completely buffered, the
>> server closes the connection before HttpClient completes the request
>> transmission. I implemented a HttpMethodRetryHandler to handle this
>> but method.getStatusCode() throws a NullPointerException. I want to  
>> be
>> able to read the response in order to determine what happened. Any
>> ideas?
>>
>
> Francesco,
>
> This is a generic problem with classic (blocking) I/O in Java. There  
> is
> simply no easy way of testing for pending input data while streaming
> data out using blocking I/O. The only feasible solution to this  
> issue is
> the use of non-blocking I/O, which has issues of its own.

Thanks this clears things up. I think i'll do some pattern matching on  
the exception, document it and hope for the best.

Thanks,

Franco
>
>
> Oleg
>
>
>> # log output of a 500MB PUT (no response seems to be given)
>> 2008/04/29 16:00:38:910 EDT [DEBUG] HttpConnection - Open connection
>> to localhost:9009
>> 2008/04/29 16:00:38:924 EDT [DEBUG] header - >> "PUT /foo HTTP/ 
>> 1.1[\r]
>> [\n]"
>> 2008/04/29 16:00:38:925 EDT [DEBUG] HttpMethodBase - Adding Host
>> request header
>> 2008/04/29 16:00:42:894 EDT [DEBUG] header - >> "User-Agent: Jakarta
>> Commons-HttpClient/3.1[\r][\n]"
>> 2008/04/29 16:00:42:894 EDT [DEBUG] header - >> "Host: localhost:
>> 9009[\r][\n]"
>> 2008/04/29 16:00:42:894 EDT [DEBUG] header - >> "Content-Length:
>> 472870912[\r][\n]"
>> 2008/04/29 16:00:42:894 EDT [DEBUG] header - >> "[\r][\n]"
>> 2008/04/29 16:00:42:895 EDT [DEBUG] HttpMethodDirector - Closing the
>> connection.
>> 2008/04/29 16:00:42:896 EDT [DEBUG] HttpConnection - Releasing
>> connection back to connection manager.
>>
>> # log output of a 1k PUT (the response is read)
>> 2008/04/29 16:20:58:945 EDT [DEBUG] HttpConnection - Open connection
>> to localhost:9009
>> 2008/04/29 16:20:58:959 EDT [DEBUG] header - >> "PUT /foo HTTP/ 
>> 1.1[\r]
>> [\n]"
>> 2008/04/29 16:20:58:960 EDT [DEBUG] HttpMethodBase - Adding Host
>> request header
>> 2008/04/29 16:20:58:973 EDT [DEBUG] header - >> "User-Agent: Jakarta
>> Commons-HttpClient/3.1[\r][\n]"
>> 2008/04/29 16:20:58:973 EDT [DEBUG] header - >> "Host: localhost:
>> 9009[\r][\n]"
>> 2008/04/29 16:20:58:974 EDT [DEBUG] header - >> "Content-Length:
>> 1024[\r][\n]"
>> 2008/04/29 16:20:58:974 EDT [DEBUG] header - >> "[\r][\n]"
>> 2008/04/29 16:20:58:974 EDT [DEBUG] EntityEnclosingMethod - Request
>> body sent
>> 2008/04/29 16:20:58:975 EDT [DEBUG] header - << "  HTTP/1.1 413 Too
>> Big[\n]"
>> 2008/04/29 16:20:58:975 EDT [DEBUG] header - << "  HTTP/1.1 413 Too
>> Big[\r][\n]"
>> 2008/04/29 16:20:58:976 EDT [DEBUG] header - << "  Content-Type:
>> none[\n]"
>> 2008/04/29 16:20:58:976 EDT [INFO] HttpMethodBase - Response content
>> length is not known
>> 2008/04/29 16:20:58:976 EDT [DEBUG] HttpMethodBase - Force-close
>> connection: true
>>
>> thanks in advance,
>> -franco
>>
>> Francesco Lazzarino
>> Florida Digital Archive Programmer
>> flaz@ufl.edu
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

Francesco Lazzarino
Florida Digital Archive Programmer
flaz@ufl.edu




---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message