You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Eugeny N Dzhurinsky <eu...@jdevelop.com> on 2005/09/15 11:39:42 UTC

Limit size of file to be downloaded

Is there any way to limit size of file to be downloaded by HTTPClient in case
if there is no content-length provided in HTTP response and file is something
like 50Mb in size?

-- 
Eugene N Dzhurinsky

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


Re: Limit size of file to be downloaded

Posted by Michael Becke <mb...@gmail.com>.
The best way is to use getResponseBodyAsStream() and read only as many
bytes are you are willing to.  If the response ends up being too long,
call HttpMethod.abort().

Mike

On 9/15/05, Eugeny N Dzhurinsky <eu...@jdevelop.com> wrote:
> Is there any way to limit size of file to be downloaded by HTTPClient in case
> if there is no content-length provided in HTTP response and file is something
> like 50Mb in size?
> 
> --
> Eugene N Dzhurinsky
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> 
>

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