首页 > Web开发 > 详细

http设置header

时间:2018-08-10 19:24:33      阅读:240      评论:0      收藏:0      [点我收藏+]
1、httpPost 设置header,header内容是在发送请求的头文件里面
HttpPost httpPost = new HttpPost(url);
如:
Accept    text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding    gzip, deflate
Accept-Language    zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3

2、StringEntity 设置header,header内容是在发送的内容里面

StringEntity stringEntity = new StringEntity(data, ToolString.encoding);
如:
<!DOCTYPE html>
<html id="spLianghui">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

3、HttpResponse 设置header,header内容是在获取返回信息的头文件里面

HttpResponse response = httpClient.execute(httpPost);

http设置header

原文:http://blog.51cto.com/1197822/2157329

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!