这几天之所以去了解这个,就是之前埋下的雷,自定义名称用了下划线_,前两天莫名其妙犯病一直获取不了,以为是被浏览器或是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-开头也没问题,但并不建议你这样干。
purchase cipro: buy ciprofloxacin over the counter – ciprofloxacin order online
http://ciprofloxacin.tech/# where can i buy cipro online
http://cytotec.club/# cytotec online
http://cytotec.club/# buy cytotec over the counter
buying cheap propecia without insurance cost of propecia no prescription cost cheap propecia for sale
cheap propecia online: order propecia no prescription – generic propecia price
https://cytotec.club/# buy cytotec online fast delivery
buy propecia tablets cheap propecia pill generic propecia for sale
purchase cipro buy cipro online canada buy cipro online without prescription
https://lisinopril.network/# prinivil 20 mg
http://nolvadex.life/# nolvadex gynecomastia
buy cytotec pills: Misoprostol 200 mg buy online – Cytotec 200mcg price
http://nolvadex.life/# nolvadex 10mg
alternative to tamoxifen tamoxifen and uterine thickening arimidex vs tamoxifen bodybuilding
Cytotec 200mcg price cytotec pills buy online buy cytotec over the counter
http://lisinopril.network/# lisinopril brand name in india
http://nolvadex.life/# tamoxifen breast cancer prevention
cytotec buy online usa: buy cytotec online – cytotec pills buy online
ciprofloxacin generic price cipro online no prescription in the usa cipro for sale
http://cytotec.club/# cytotec abortion pill
is nolvadex legal tamoxifen buy does tamoxifen cause bone loss
http://finasteride.store/# generic propecia price
https://finasteride.store/# generic propecia without insurance
ciprofloxacin order online buy cipro cheap ciprofloxacin generic price
lisinopril oral: 90 lisinopril – lisinopril 20 mg brand name
cost of cheap propecia tablets get generic propecia without dr prescription get generic propecia without dr prescription
https://lisinopril.network/# lisinopril 5
https://nolvadex.life/# tamoxifen citrate pct
http://finasteride.store/# buy propecia price
lisinopril 5 mg daily lisinopril 25 mg price lisinopril 500 mg
п»їcipro generic cipro ciprofloxacin ciprofloxacin order online
buying generic propecia for sale: propecia generic – cost propecia for sale
https://finasteride.store/# cost of generic propecia price
https://cytotec.club/# cytotec buy online usa
antibiotics cipro where can i buy cipro online buy cipro online canada
lisinopril 10 mg online lisinopril 12.5 tablet cost of generic lisinopril
cost of generic propecia without insurance: cost of generic propecia tablets – cost generic propecia online
https://nolvadex.life/# tamoxifen bone pain
http://finasteride.store/# cost of generic propecia without rx
generic propecia pills propecia for sale propecia brand name
https://cytotec.club/# cytotec abortion pill
order lisinopril online us lisinopril 2.5 lisinopril 5 mg pill
https://finasteride.store/# get cheap propecia no prescription
order propecia no prescription: buy cheap propecia online – buying cheap propecia price
http://cytotec.club/# order cytotec online
buy cipro ciprofloxacin over the counter where can i buy cipro online
lisinopril tabs 10mg generic 10mg lisinopril lisinopril generic price comparison
https://cytotec.club/# buy cytotec in usa
http://finasteride.store/# buy generic propecia no prescription
Misoprostol 200 mg buy online: buy cytotec – Abortion pills online