Return-Path: Delivered-To: apmail-hc-httpclient-users-archive@www.apache.org Received: (qmail 3005 invoked from network); 20 Jan 2009 05:48:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Jan 2009 05:48:57 -0000 Received: (qmail 95530 invoked by uid 500); 20 Jan 2009 05:48:56 -0000 Delivered-To: apmail-hc-httpclient-users-archive@hc.apache.org Received: (qmail 95238 invoked by uid 500); 20 Jan 2009 05:48:55 -0000 Mailing-List: contact httpclient-users-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-users@hc.apache.org Received: (qmail 95227 invoked by uid 99); 20 Jan 2009 05:48:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Jan 2009 21:48:55 -0800 X-ASF-Spam-Status: No, hits=2.6 required=10.0 tests=DNS_FROM_OPENWHOIS,SPF_HELO_PASS,SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Jan 2009 05:48:47 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1LP9TO-0003DX-D5 for httpclient-users@hc.apache.org; Mon, 19 Jan 2009 21:48:26 -0800 Message-ID: <21557478.post@talk.nabble.com> Date: Mon, 19 Jan 2009 21:48:26 -0800 (PST) From: arnab_ghosh To: httpclient-users@hc.apache.org Subject: FileDownload using HttpClient MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: arnab.ghosh2@wipro.com X-Virus-Checked: Checked by ClamAV on apache.org Hi, 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 BufferedInputStream(getMethod.getResponseBodyAsStream()); } catch (Exception e) { } finally { getMethod.releaseConnection(); } 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