Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# httpwebrequest请求的顺序_C#_.net_Http_Http Headers - Fatal编程技术网

C# httpwebrequest请求的顺序

C# httpwebrequest请求的顺序,c#,.net,http,http-headers,C#,.net,Http,Http Headers,我使用HttpWebRequest在c中发送请求# 请求应如下所示: POST https://website.com/file HTTP/1.1 Host: api.website.com User-Agent: useragent Content-Length: 81 Accept: */* Accept-Language: en;q=1, fr;q=0.9, de;q=0.8, ja;q=0.7, nl;q=0.6, it;q=0.5 Content-Type: application/x

我使用HttpWebRequest在c中发送请求#

请求应如下所示:

POST https://website.com/file HTTP/1.1
Host: api.website.com
User-Agent: useragent
Content-Length: 81
Accept: */*
Accept-Language: en;q=1, fr;q=0.9, de;q=0.8, ja;q=0.7, nl;q=0.6, it;q=0.5
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Accept-Encoding: gzip, deflate
Connection: keep-alive
POST https://website.com/file HTTP/1.1
Accept-Encoding: gzip, deflate
Accept-Language: en;q=1, fr;q=0.9, de;q=0.8, ja;q=0.7, nl;q=0.6, it;q=0.5
User-Agent: useragent
Accept: */*
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Host: api.website.com
Content-Length: 97
Connection: Keep-Alive
但它是这样表现的:

POST https://website.com/file HTTP/1.1
Host: api.website.com
User-Agent: useragent
Content-Length: 81
Accept: */*
Accept-Language: en;q=1, fr;q=0.9, de;q=0.8, ja;q=0.7, nl;q=0.6, it;q=0.5
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Accept-Encoding: gzip, deflate
Connection: keep-alive
POST https://website.com/file HTTP/1.1
Accept-Encoding: gzip, deflate
Accept-Language: en;q=1, fr;q=0.9, de;q=0.8, ja;q=0.7, nl;q=0.6, it;q=0.5
User-Agent: useragent
Accept: */*
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Host: api.website.com
Content-Length: 97
Connection: Keep-Alive

我试图搜索如何更改httpwebrequest的顺序,但找不到任何内容。

如果您的服务器依赖于标题的顺序,我认为它已损坏。我不希望顺序是有保证的或有意义的-为什么你的代码对它敏感?你不会改变标题的顺序吗?为什么这么重要?web服务器有一个安全检查来检查头的顺序。所以我必须保持这种方式。向他们展示RFC的这一部分:。的副本,答案是:不,如果您确实需要,请使用套接字自己编写HTTP客户端。