2

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!

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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~!
You don't need any HttpConnect class. The connection logic is implemented inside HttpGet and HttpPost classes and are invisible to you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.