在HttpMethodBase类中,关键方法1:
public int execute(HttpState state, HttpConnection conn)
throws HttpException, IOException {
LOG.trace("enter HttpMethodBase.execute(HttpState, HttpConnection)");
// this is our connection now, assign it to a local variable so
// that it can be released later
this.responseConnection = conn;
checkExecuteConditions(state, conn);
this.statusLine = null;
this.connectionCloseForced = false;
conn.setLastResponseInputStream(null);
// determine the effective protocol version
if (this.effectiveVersion == null) {
this.effectiveVersion = this.params.getVersion();
}
writeRequest(state, conn);
this.requestSent = true;
readResponse(state, conn);
// the method has successfully executed
used = true;
return statusLine.getStatusCode();
}
关键方法2:
protected void readResponse(HttpState state, HttpConnection conn)
throws IOException, HttpException {
LOG.trace(
"enter HttpMethodBase.readResponse(HttpState, HttpConnection)");
// Status line & line may have already been received
// if 'expect - continue' handshake has been used
while (this.statusLine == null) {
readStatusLine(state, conn);
processStatusLine(state, conn);
readResponseHeaders(state, conn);
processResponseHeaders(state, conn);
int status = this.statusLine.getStatusCode();
if ((status >= 100) && (status < 200)) {
if (LOG.isInfoEnabled()) {
LOG.info("Discarding unexpected response: " + this.statusLine.toString());
}
this.statusLine = null;
}
}
readResponseBody(state, conn);
processResponseBody(state, conn);//此方法为空,可以被子类覆写
}
看代码,http头是被httpclient直接处理的,但是body就没有处理了,直接保留了stream没有去读。
分享到:
相关推荐
HttpClient3.1 亲测可用,放心使用
HttpClient3.1 学习整理,应用HttpClient来对付各种顽固的WEB服务器
HttpClient 3.1 jar包 SSL https 实现方式可进入我的博客 http://blog.csdn.net/homebei2 查看
httpclient3.1 需要的jar
commons-httpClient 3.1 jar和src
包含最新的更新,源代码和手册,值得一下.
httpclient3.1 javadoc chm版
httpclient3.1和2个相关的jar包
HttpClient是Apache Jakarta Common下的子项目,用来提供高效的、最新的、功能丰富的支持...HttpClient已经应用在很多的项目中,比如Apache Jakarta上很著名的另外两个开源项目Cactus和HTMLUnit都使用了HttpClient。
httpclient 3.1已经改写,不需要再设定字符编码统一设定为UTF-8
commons-httpclient-3.1 源代码
commons-httpclient-3.1-beta1.jar
commons-httpclient-3.1jar包,有需要的请下载 本资料共包含以下附件: commons-httpclient-3.1jar包.rar
org.apache.commons.httpclient-3.1.jar 用于解决httpclient jar包依赖!!!
httpclient-3.1網絡,個人覺得以android自己的網絡連接好用,以后會經常用這個來寫代碼了,呵呵!
Apache推出的httpClient 3.1 导入Eclipse方法: 1.解压zip,找出3个jar文件,放入一个你想放的文件夹中 2.右键Eclipse中的工程,选择Build Path->Configure Build Path 3.选择Add External Jar,选择解压得到的3...