webrequest Headers的顺序是否重要? [英] Is the order of webrequest Headers important?

查看:239
本文介绍了webrequest Headers的顺序是否重要?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在发送POST请求将图片上传到网站。

在页面中,有一个 FileUpload 和一个输入 (textBox)并且在fiddler中我发现页面正在使用Multipart Post请求模式发送一些数据(内容处理:multipart-formdata;)

一切似乎都没问题,因为小提琴手的内容与我的应用发布的内容以及页面发送的内容相同...只是不关于标题顺序...

I'm making a POST request to upload a picture to a website.
In the page, there is one FileUpload and one input (textBox) and in fiddler I found out that the page is sending some data using Multipart Post request mode (Content Disposition: multipart-formdata;)
Everything seems to be OK, coz in fiddler everything is the same about what my app is posting and what the page is sending... Just not about headers order...

我的问题是将标题按正确的顺序排列真的很重要吗?如果是,我该怎么办? (因为我们只是在请求中设置一些属性,没有在哪里设置订单...)

My question is that is it really important to put headers in a right order? and if yes, how can I do it? (as we are just setting some properties in request, there is no where to set the order...)

感谢任何建议......

thanks for any advise...

推荐答案

对于具有不同名称的标头,HTTP标头的顺序无关紧要。但是,如果有多个具有相同名称的标题,则顺序很重要。

The order of HTTP Headers doesn't matter for headers with different names. If there are multiple headers with the same name, however, the order is important.

请参阅 RFC 2616


标题字段的顺序不同的字段名称是
收到的不重要
。但是,首先发送
通用标头字段,然后是request-header或response-
标头字段,并以entity-header字段结束是良好做法。

The order in which header fields with differing field names are received is not significant. However, it is "good practice" to send general-header fields first, followed by request-header or response- header fields, and ending with the entity-header fields.

当且仅当该
头字段的整个字段值被定义为时,消息中存在具有相同字段名称的多个消息头字段可能是
以逗号分隔的列表[即#(值)]。
必须可以将多个头字段组合成一个
field-name:field-value对,而不需要通过附加每个后续字段值来更改
消息的语义到第一个,每个
用逗号分隔。 因此,收到具有相同
字段名称的标题字段的顺序对于组合字段值的
解释非常重要
,因此代理必须不是
转发邮件时更改这些字段值的顺序。

Multiple message-header fields with the same field-name MAY be present in a message if and only if the entire field-value for that header field is defined as a comma-separated list [i.e., #(values)]. It MUST be possible to combine the multiple header fields into one "field-name: field-value" pair, without changing the semantics of the message, by appending each subsequent field-value to the first, each separated by a comma. The order in which header fields with the same field-name are received is therefore significant to the interpretation of the combined field value, and thus a proxy MUST NOT change the order of these field values when a message is forwarded.

这篇关于webrequest Headers的顺序是否重要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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