这几天之所以去了解这个,就是之前埋下的雷,自定义名称用了下划线_,前两天莫名其妙犯病一直获取不了,以为是被浏览器或是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-开头也没问题,但并不建议你这样干。
ed online prescription cheap ed pills online ed pills cheap
erectile dysfunction meds online: cheap erectile dysfunction pills – online ed treatments
http://onlinepharmacyworld.shop/# canadian pharmacy no prescription needed
online pharmacies without prescription canada pharmacies online prescriptions canadian rx prescription drugstore
legal online pharmacy coupon code: offshore pharmacy no prescription – rx pharmacy coupons
ed treatments online get ed meds online ed medicines
http://medicationnoprescription.pro/# no prescription
erectile dysfunction drugs online: affordable ed medication – ed medications cost
http://edpill.top/# pills for erectile dysfunction online
order ed pills online best online ed meds affordable ed medication
erectile dysfunction medication online: erectile dysfunction meds online – cheap ed pills online
affordable ed medication: cheap ed pills – buying ed pills online
https://medicationnoprescription.pro/# п»їonline pharmacy no prescription needed
no prescription needed online pharmacy online pharmacies no prescription pharmacy no prescription
http://medicationnoprescription.pro/# non prescription canadian pharmacy
http://stromectola.top/# stromectol pill
get clomid tablets where to buy generic clomid online generic clomid price
where to get clomid without dr prescription: buying cheap clomid online – can i buy clomid without a prescription
http://azithromycina.pro/# zithromax 250 mg australia
purchase zithromax online: zithromax 500mg price – purchase zithromax z-pak
where to buy prednisone uk mail order prednisone generic prednisone tablets
http://azithromycina.pro/# where can i purchase zithromax online
zithromax for sale online buy zithromax online can i buy zithromax over the counter
https://stromectola.top/# what is minocycline 50 mg used for
where buy cheap clomid pill: buying generic clomid no prescription – can i buy cheap clomid for sale
generic clomid without insurance clomid no prescription can i order generic clomid online
ivermectin 80 mg: buy ivermectin stromectol – stromectol over the counter
how much is zithromax 250 mg: can you buy zithromax over the counter – zithromax for sale cheap
prednisone prednisone capsules cost of prednisone 40 mg
https://clomida.pro/# where can i buy generic clomid
doxycycline hyc 100mg doxycycline pills how to buy doxycycline online
http://nolvadex.icu/# tamoxifen hormone therapy
buy cytotec: п»їcytotec pills online – buy misoprostol over the counter
where can i buy diflucan without prescription diflucan tablet price in india how to buy diflucan over the counter
diflucan cream india diflucan 300 mg diflucan 400mg
tamoxifen for gynecomastia reviews: tamoxifen pill – does tamoxifen make you tired
tamoxifen generic: benefits of tamoxifen – buy nolvadex online
cytotec online cytotec online buy cytotec
http://nolvadex.icu/# tamoxifen hot flashes
buy cheap doxycycline buy doxycycline without prescription buy doxycycline without prescription uk
how to buy doxycycline online: vibramycin 100 mg – doxycycline hyclate
diflucan 110 mg diflucan online prescription best diflucan price
Abortion pills online: cytotec pills buy online – cytotec online
doxycycline 100mg tablets doxycycline hyclate 100 mg cap buy generic doxycycline
buy cipro online: cipro pharmacy – cipro online no prescription in the usa
https://doxycyclinest.pro/# doxylin
nolvadex vs clomid tamoxifen adverse effects tamoxifen dosage
where to purchase doxycycline doxycycline hyclate 100 mg cap doxylin
doxycycline prices: buy cheap doxycycline online – vibramycin 100 mg
ciprofloxacin mail online: cipro online no prescription in the usa – ciprofloxacin 500 mg tablet price