hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: making a client for downloading file through http
Date Fri, 06 Nov 2009 15:05:04 GMT
Håkon Sagehaug wrote:
> Hi all,
> 
> I'm making a web service that should be bale to download files from ftp,
> http etc. And now I-m making the http part and wondering the best way of
> doing that using the httpcomponents libraries. The files that can be
> downloaded can be small or large(100->Mb).  The scenario is that the client
> gives the service a ftp or http url and the service downloads it to the
> services local file system.
> For now I've used the http core package for downloading files, without
> connection re-use but will add that. So my question is what is the most
> efficient way of doing this using the libraries.

Hi Håkon

I think HttpCore (classic) is a good choice as long as you do not mind 
managing connection persistence in your code.

  I've looked a little at nio
> component. What I want i guess is that the client calling the service should
> not wait until the download is complete before an response is given, but
> just be notified that the download has been started. I guess one option is
> to do that in a thread, another is to use httpnio
> 

I do not think HttpCore NIO is necessary in such a case. NIO is 
_significantly_ more complex and in my opinion offers little benefit for 
client side HTTP. HttpCore (classic) will only block until a response 
head is fully received. So, your could can examine the status code and 
headers before downloading the response body from the content input 
stream. I see little wrong with using a worker thread to download the 
response content as long as the number of worker threads remains low 
(<50 or so).

> Any tips or suggestions how to solve this?
> 

Hope this answers your question.

Cheers

Oleg

> cheers, Håkon
> 


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