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 Tatiana Lloret Iglesias <tl...@gmail.com> on 2007/10/25 19:23:23 UTC

Download a .zip through https

 Hi all,

in my jsp i have a link which is linked with a .zip under https.

When i click on the link i should have the possibility of opening that .zip
to save it locally

I have the following source code which works but i don't know what to do
with the InputStream in ....
Thanks!
T


HttpClient client = new HttpClient();

HostConfiguration host = client.getHostConfiguration();
host.setHost(new URI("https://www.host.com", true));

client.getState().setCredentials(
new AuthScope(host.getHost(), 443,AuthScope.ANY_REALM),
new UsernamePasswordCredentials("xxxx", "ddddd")
);

get = new GetMethod("https://www.host.com/dd/ss/ee.zip");

get.setDoAuthentication( true );

// execute the GET
int status = client.executeMethod( get );

//get the resonse as an InputStream
InputStream in =
get.getResponseBodyAsStream();

Re: Download a .zip through https

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2007-10-25 at 19:23 +0200, Tatiana Lloret Iglesias wrote:
> Hi all,
> 
> in my jsp i have a link which is linked with a .zip under https.
> 
> When i click on the link i should have the possibility of opening that .zip
> to save it locally
> 
> I have the following source code which works but i don't know what to do
> with the InputStream in ....

Try reading from it.

Oleg


> Thanks!
> T
> 
> 
> HttpClient client = new HttpClient();
> 
> HostConfiguration host = client.getHostConfiguration();
> host.setHost(new URI("https://www.host.com", true));
> 
> client.getState().setCredentials(
> new AuthScope(host.getHost(), 443,AuthScope.ANY_REALM),
> new UsernamePasswordCredentials("xxxx", "ddddd")
> );
> 
> get = new GetMethod("https://www.host.com/dd/ss/ee.zip");
> 
> get.setDoAuthentication( true );
> 
> // execute the GET
> int status = client.executeMethod( get );
> 
> //get the resonse as an InputStream
> InputStream in =
> get.getResponseBodyAsStream();


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