这几天之所以去了解这个,就是之前埋下的雷,自定义名称用了下划线_,前两天莫名其妙犯病一直获取不了,以为是被浏览器或是nginx拦截了,开始考虑是否是这个名称的问题,然而debug两天,结果是代码里一个变量名忘了改......我的天,我真的会哭
正文
- 第一点,既然这个字段是我们自定义的,那名称肯定要避开协议中已经存在的字段的名称(如Host,Referer等都不能用)
- 注意请求头的名称不区分大小写,但会区分 - _ 等符号
- 例如:
- HelloWorld和helloworld等价,如果请求头中实际名称是HelloWorld,但在读取时直接传入helloworld也是可以获取到的。(因为标准是这么规定的,解析库在设计时也应当支持这个操作)
- HelloWorld 和 Hello-World 和 Hello_World,三者都不一样
- 例如:
- 名称里不应包含 空白符、换行符、下划线、冒号
- 连接符号可以使用短横杠,即减号 -
- 例如:
- 允许:HelloWorld、Hello-World、helloworld
- 但不应:Hello World、Hello:World、Hello_world等
- 其中,如果硬要使用下划线_,在nginx的nginx.conf配置文件内的http部分内需要配置一句:
- underscores_in_headers on;
- 这句配置会允许nginx放行包含下划线的请求头字段,否则nginx会默认把上述不符合要求的几种情况的字段全部去掉,然后再把这个请求转发过来,因此导致后端程序获取不到自定义的那个字段。
- 有时我们会看到一些网站在命名自定义字段时使用 X- 开头的格式,然而早在2012年6月,标准RFC 6648就明确弃用这一建议:
3.对新参数的创建者的建议
......
不建议在其参数名称前加上“X-”或类似的结构。
对协议设计者的建议
......
不应禁止注册具有“X-”前缀或类似结构的参数。
绝不能规定具有“X-”前缀或类似结构的参数需要被理解为非标准化。
绝不能规定没有“X-”前缀或类似结构的参数需要被理解为标准化。
- -
- 也就是说,X- 并没有什么特别的效果,它是以前的一种规范建议,而现在已经不建议了,继续用X-开头也没问题,但并不建议你这样干。
cytotec buy online usa cytotec online cytotec abortion pill
cost generic clomid: where to buy clomid without dr prescription – can i purchase clomid now
cost of cheap propecia tablets: cost of propecia – cheap propecia price
http://lisinopril.club/# lisinopril 12.5 20 g
neurontin canada: gabapentin 600 mg – drug neurontin
buy cytotec over the counter buy cytotec over the counter buy cytotec online fast delivery
generic gabapentin: order neurontin – neurontin 400 mg tablets
lisinopril 5 mg brand name in india lisinopril 102 25 mg lisinopril
cost of neurontin: neurontin 300mg – buy neurontin online no prescription
http://propeciaf.online/# cost of propecia without dr prescription
get cheap clomid without insurance: cheap clomid price – clomid generics
http://clomiphene.shop/# cheap clomid online
zestril over the counter lisinopril 20 mg brand name lisinopril medication generic
neurontin 100 mg cost neurontin 300 mg mexico prescription price for neurontin
https://clomiphene.shop/# how to buy generic clomid without rx
how can i get clomid prices: how to get generic clomid online – how can i get cheap clomid price
cost of cheap clomid pill: cost clomid without insurance – buy clomid pills
http://gabapentin.club/# neurontin brand name 800 mg
order generic propecia without dr prescription buying cheap propecia without prescription cost cheap propecia tablets
neurontin uk neurontin medication neurontin cost
Hi i think that i saw you visited my web site thus i came to Return the favore Im attempting to find things to enhance my siteI suppose its ok to use a few of your ideas
http://lisinopril.club/# prinivil 20 mg cost
cheapest lisinopril 10 mg: generic for prinivil – lisinopril medication generic
Cytotec 200mcg price: purchase cytotec – cytotec buy online usa
order generic propecia pills buying cheap propecia without prescription get generic propecia without dr prescription
buy neurontin 300 mg neurontin capsules 100mg generic neurontin 300 mg
where can i buy cheap clomid: can i purchase clomid without prescription – can i buy cheap clomid tablets
neurontin 202: neurontin 500 mg – neurontin 214
http://gabapentin.club/# neurontin 10 mg
neurontin capsules 300mg: neurontin 204 – over the counter neurontin
http://clomiphene.shop/# where buy clomid prices
neurontin for sale online neurontin 100mg discount neurontin 300 mg tablets
order cytotec online purchase cytotec buy cytotec in usa
cost of neurontin 600mg: drug neurontin 20 mg – cost of neurontin 600 mg
http://cytotec.xyz/# Abortion pills online
lipinpril: lisinopril 12.5 mg 20 mg – lisinopril 15 mg tablets
brand name neurontin price neurontin 900 neurontin discount
can i get generic clomid without rx clomid prices buying cheap clomid online
http://cytotec.xyz/# cytotec abortion pill
cost generic clomid now: how to buy clomid – order cheap clomid now
order propecia for sale: generic propecia price – cost generic propecia online
zestril 20 mg tab prinivil coupon lisinopril 10 mg no prescription
https://gabapentin.club/# neurontin online pharmacy
http://cytotec.xyz/# buy cytotec pills online cheap
get cheap clomid no prescription: get cheap clomid – clomid without a prescription
mexican pharmaceuticals online mexican drugstore online mexican mail order pharmacies
reputable mexican pharmacies online mexican border pharmacies shipping to usa buying prescription drugs in mexico
https://mexicanpharmacy1st.com/# purple pharmacy mexico price list
purple pharmacy mexico price list: mexico drug stores pharmacies – mexican drugstore online
https://mexicanpharmacy1st.shop/# buying prescription drugs in mexico