hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arnab_ghosh <arnab.gho...@wipro.com>
Subject FileDownload using HttpClient
Date Tue, 20 Jan 2009 05:48:26 GMT


I am using HttpClient for generating a FileDownLoad. 
Let me give a small explanation of the scenario.

I have Webservice which returns me a file as an InputStream. I am using
Stripes as the Web Framework.
Here goes the code:

       .....Other code
       try {
             HttpClient httpClient = new HttpClient();
             GetMethod getMethod = new GetMethod(assetURL);
             bufferedInputstream = new
      } catch (Exception e) {
      } finally {
      StreamingResolution streamingResolution = new
StreamingResolution(contentType, bufferedInputstream);
    // set the fileName in the StreamingResolution.This in turn sets the
appropriate response header.
    streamingResolution.setFilename(fileName + "." + extension)

    // return the FileInputStream wrapped in the resolution
    return streamingResolution;

The problem I am facing is, If i close the connection in the finally block,
it throws IOException: Tring to read from an already closed Stream.

So can you tell me when will be the correct time to close the connection?
What is the correct way for FileDownload via HTTPClient?

Can you help?
View this message in context: http://www.nabble.com/FileDownload-using-HttpClient-tp21557478p21557478.html
Sent from the HttpClient-User mailing list archive at Nabble.com.

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

View raw message