Hi guys:
There are several methods such as HttpGet and HttpPost in this package. But the CONNECT method is lost. Do you know why ? I've tried to add my own HTTP CONNECT method following the HttpGet method implementation. i.e. new the class HttpConnect which extends the HttpEntityEnclosingRequestBase base class. But this does not work. :-(
May you please help? Thank you!
Add a comment
|
1 Answer
You do not have to implement any connect method. Check out the example provided in official documentation:
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("http://localhost/");
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream instream = entity.getContent();
int l;
byte[] tmp = new byte[2048];
while ((l = instream.read(tmp)) != -1) {
}
}
Refer to sources and documentation.
2 Comments
James
Ye, You've given me a sample how to execute HttpGet command. But how to execute a HttpConnect command ??? There's no class called HttpConnect in the APIs. Thank you~!
Vladimir Ivanov
You don't need any HttpConnect class. The connection logic is implemented inside HttpGet and HttpPost classes and are invisible to you.