ITPub博客

首页 > IT职业 > IT生活 > http设置header

http设置header

IT生活 作者:johnchou 时间:2021-09-09 10:09:14 0 删除 编辑

1、httpPost 设置header,header内容是在发送请求的头文件里面

HttpPost httpPost = new HttpPost(url);如:Accept    text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Encoding    gzip, deflateAccept-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);

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4422/viewspace-2817560/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2020-11-13

  • 博文量
    80
  • 访问量
    7438