HttpPost addHeader不起作用 - 标题不受影响

时间:2014-02-16 18:34:25

标签: c# java android http-headers

在Java / Android中使用HttpPost时,我无法使用addHeaders方法。这就是我在Android应用中所做的事情:

HttpClient client = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.addHeader("Accept-Encoding", "gzip");
StringEntity entity = new StringEntity(jsonString, HTTP.UTF_8);
httpPost.setEntity(entity);
HttpResponse resp = client.execute(httpPost);

这就是我在服务器端看到的(在Wireshark中):

enter image description here

如您所见,没有任何“Accept-Encoding”的迹象。如果我打破C#-server并查看WebOperationContext.Current.IncomingRequest,那么它也会丢失:

enter image description here

我添加的标题无关紧要,它们根本不显示。

0 个答案:

没有答案
相关问题