[C#]在PCL System.Net.Http.HttpClient中缺少http标头 [英] [C#]Missing http headers in PCL System.Net.Http.HttpClient

查看:171
本文介绍了[C#]在PCL System.Net.Http.HttpClient中缺少http标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


您好,

Hi,

我正在使用PCL发送http请求
HttpClient

I'm sending a http request using PCL HttpClient.

OPTIONS http://XXXXXXXXXX/ HTTP/1.1
Content-Length: 0
Connection: Keep-Alive
Pragma: no-cache
Authorization: Basic XXXXXXXXXXXXXXX==

返回

HTTP/1.1 200 OK
Date: Thu, 21 Jan 2016 14:52:23 GMT
Server: Apache
X-Powered-By: PHP/5.6.16
Allow: OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT, LOCK, UNLOCK
DAV: 1, 3, extended-mkcol, 2
MS-Author-Via: DAV
Accept-Ranges: bytes
X-Sabre-Version: 1.5.8
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Keep-Alive: timeout=5, max=498
Connection: Keep-Alive

推荐答案

Hello Alvaro Rivoir,

Hello Alvaro Rivoir,

以下内容应该有效。回复。 标题 是与HttpResponseMessage关联的HTTP响应标头的集合    
由服务器发送。

The following should work. Response.Headers are the collection of HTTP response headers associated with the HttpResponseMessage     that were sent by the server.

string values;
response.Headers.TryGetValue("Allow",out values);

你能提供你测试过的URL吗?尝试使用官方样本进行测试。

Could you provide the URL on which you tested this? Try using the official sample to test this.

请参阅: https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/HttpClient

问候,

Krunal Parekh

Krunal Parekh


这篇关于[C#]在PCL System.Net.Http.HttpClient中缺少http标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆