java-apache客户端http响应以处理状态码http 100
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java-apache客户端http响应以处理状态码http 100,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1303字,纯文字阅读大概需要2分钟。
内容图文
![java-apache客户端http响应以处理状态码http 100](/upload/InfoBanner/zyjiaocheng/654/de90126a9c38410fa3372d4479899c22.jpg)
我使用apache httpdefault客户端并执行如下发布功能
HttpResponse imToken = httpClient.execute(httpPostIM);
得到的响应是
HTTP/1.1 100 Continue
Connection: keep-alive
其次是:
HTTP/1.1 200 OK
Date: Tue, 30 Aug 2011 19:11:35 GMT
我们如何从客户端处理呢?
解决方法:
这是response 100 from w3的定义,这是what the response looks like的一个很好的示例.
The client SHOULD continue with its request. This interim response is used to inform the client that the initial part of the request has been received and has not yet been rejected by the server. The client SHOULD continue by sending the remainder of the request or, if the request has already been completed, ignore this response. The server MUST send a final response after the request has been completed. See section 8.2.3 for detailed discussion of the use and handling of this status code.
因此,如果您的客户端已经发送了整个请求,则它应该等待服务器等待,直到给出200或其他“最终”响应.
根据Apache HttpClient代码,您无需执行任何操作,因为客户端将忽略所有1XX响应代码,并继续寻找最终响应.这来自HttpMethodBase类的commons-httpclient-3.1:
if ((status >= 100) && (status < 200)) {
if (LOG.isInfoEnabled()) {
LOG.info("Discarding unexpected response: " +
this.statusLine.toString());
}
this.statusLine = null;
}
如果您没有看到此行为,那么也许您需要增加客户端超时时间?也许等待的时间不够长?
内容总结
以上是互联网集市为您收集整理的java-apache客户端http响应以处理状态码http 100全部内容,希望文章能够帮你解决java-apache客户端http响应以处理状态码http 100所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。