Hi,i am useing HttpClient 4.0-beta2, to do rest call,
it works fine in my lap-top, but in uni, we have to config our application to go through a proxy, otherwise, we cannot connect to internet
Here is my orginal code:
HttpClient httpclient = new DefaultHttpClient();
HttpPut put = new HttpPut("http://" + PutBlob.ACCOUNT + ".blob.core.windows.net/container/abc");
put.addHeader(PutBlob.ContentType, PutBlob.CONTENT_TYPE.TEXT_PLAIN.getValue());
put.setEntity(new StringEntity("Hello world", "UTF-8"));
Sign(put, PutBlob.ACCOUNT, PutBlob.KEY);
log.debug(EntityUtils.toString(httpclient.execute(put).getEntity()));
And below is how i use proxy, but it didn`t work for me, what is the right way to config proxy in HttpClient4.0 ???
HttpHost hcProxyHost = new HttpHost("proxyserver", 3128, "http");
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, hcProxyHost);
HttpPut put = new HttpPut("/container/abc");
put.addHeader(PutBlob.ContentType, PutBlob.CONTENT_TYPE.TEXT_PLAIN.getValue());
put.setEntity(new StringEntity("Hello world", "UTF-8"));
Sign(put, PutBlob.ACCOUNT, PutBlob.KEY);
HttpHost target = new HttpHost( PutBlob.ACCOUNT + ".blob.core.windows.net");
log.debug(EntityUtils.toString(httpclient.execute(target, put).getEntity()));