Hi Marcus,

Thanks once again for such prompt reply.
I understood the the stream will be closed. But this HttpClient creates a
connection for fetching the response. It says that the connection should be
released, once response is read.

I will provide you the code snippet for your help:
try {
      GetMethod getMethod = new GetMethod(assetURL);
      int statusCode = httpClient.executeMethod(getMethod);

      log.info("statusCode : {}", statusCode);

      // Wrap the InputStream in a BufferedInputStream 
      bufferedInputstream = new
BufferedInputStream(getMethod.getResponseBodyAsStream());

      // Get the content type of the file
      contentType = getMethod.getResponseHeader("content-type").getValue();
      log.info("The contentType : {}", contentType);

      // Create a StreamingResolution with inputStream
      streamingResolution = new StreamingResolution(contentType,
bufferedInputstream);

    } catch (IOException ioEx) {
      log.error("Error occurred: " + ioEx.getMessage(), ioEx);
    } finally {

       getMethod.releaseConnection(); // This line if presently closes the
Stream abruptly
    }

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

execute method will close the Stream but how will the connection be
released?



Regards
Arnab

M.C.S. wrote:
> 
> Hi Arnab,
> 
> arnab_ghosh wrote:
>> I have used HttpClient for getting the InputStream from a web service.
>> Will
>> the StreamingResolution also release the connection?
>>   
> 
> after streaming the StreamingResolution will close any InputStream you
> pass on to it. It does not matter where you obtained the stream.
> 
> Regards
> Marcus
> 
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by:
> SourcForge Community
> SourceForge wants to tell your story.
> http://p.sf.net/sfu/sf-spreadtheword
> _______________________________________________
> Stripes-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/stripes-users
> 
> 

-- 
View this message in context: 
http://www.nabble.com/File-Download-in-Stripes-using-HttpClient-tp21558239p21559930.html
Sent from the stripes-users mailing list archive at Nabble.com.


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to