org.apache.http.client.methods

问题描述 投票:2回答:1

嗨伙计们:这个包中有几种方法,如HttpGetHttpPost。但是CONNECT方法丢失了。你知道为什么吗 ?我试图在HttpGet方法实现之后添加我自己的HTTP CONNECT方法。即新增的HttpConnect类,它扩展了HttpEntityEnclosingRequestBase基类。但这不起作用。 :-(你能帮忙吗?谢谢!

android http
1个回答
2
投票

您不必实现任何连接方法。查看官方文档中提供的示例:

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) {
    }
}

请参阅sources and documentation

© www.soinside.com 2019 - 2024. All rights reserved.