这几天之所以去了解这个,就是之前埋下的雷,自定义名称用了下划线_,前两天莫名其妙犯病一直获取不了,以为是被浏览器或是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-开头也没问题,但并不建议你这样干。
gГјnstigste online apotheke: gГјnstigste online apotheke – gГјnstige online apotheke
pharmacie en ligne pas cher: vente de mГ©dicament en ligne – pharmacie en ligne fiable
online apotheke: internet apotheke – online apotheke gГјnstig
https://eufarmacieonline.shop/# farmacie online sicure
europa apotheke gГјnstigste online apotheke online apotheke gГјnstig
comprare farmaci online all’estero: comprare farmaci online con ricetta – farmacia online
Achat mГ©dicament en ligne fiable pharmacie en ligne pas cher pharmacies en ligne certifiГ©es
farmacia online: farmaci senza ricetta elenco – farmaci senza ricetta elenco
medikamente rezeptfrei: beste online-apotheke ohne rezept – п»їshop apotheke gutschein
online apotheke gГјnstig: online apotheke versandkostenfrei – gГјnstige online apotheke
ohne rezept apotheke: online apotheke – online apotheke versandkostenfrei
farmacias online seguras farmacia barata farmacia online madrid
farmacia online espaГ±a envГo internacional: farmacia online envГo gratis – farmacias online baratas
pharmacie en ligne france livraison belgique pharmacie en ligne sans ordonnance pharmacie en ligne france pas cher
п»їfarmacia online espaГ±a: farmacias online seguras en espaГ±a – farmacia online barata y fiable
Farmacie on line spedizione gratuita: top farmacia online – farmacie online affidabili
pharmacies en ligne certifiГ©es: pharmacie en ligne sans ordonnance – п»їpharmacie en ligne france
migliori farmacie online 2024: farmacie online autorizzate elenco – farmacie online sicure
farmaci senza ricetta elenco farmacie online autorizzate elenco farmacie online sicure
http://eufarmacieonline.com/# Farmacie online sicure
reputable mexican pharmacies online pharmacies in mexico that ship to usa mexico pharmacy
canada pharmacy online cheapest canada canadian pharmacy king
http://cheapestandfast.com/# mexican pharmacies no prescription
https://cheapestcanada.com/# canadian pharmacy meds reviews
medication from mexico pharmacy: mexico drug stores pharmacies – mexican pharmaceuticals online
online pharmacy with prescription cheapest and fast п»їonline pharmacy no prescription needed
https://cheapestcanada.shop/# legal canadian pharmacy online
https://cheapestmexico.shop/# best mexican online pharmacies
п»їlegitimate online pharmacies india: indian pharmacy online – india pharmacy mail order
https://cheapestmexico.shop/# mexican online pharmacies prescription drugs
http://cheapestandfast.com/# mexico prescription drugs online
mexican border pharmacies shipping to usa buying from online mexican pharmacy best online pharmacies in mexico
https://cheapestcanada.com/# best canadian pharmacy to order from
reputable online pharmacy no prescription: 36 & 6 health – prescription drugs online
https://cheapestmexico.com/# mexican rx online
non prescription medicine pharmacy: 36 and 6 pharmacy – best canadian pharmacy no prescription
legit canadian pharmacy precription drugs from canada canadian pharmacy
https://cheapestandfast.com/# online medicine without prescription
online shopping pharmacy india indian pharmacy online best online pharmacy india
https://36and6health.shop/# canada drugs coupon code
https://cheapestmexico.com/# mexican drugstore online
canada pharmacy online cheapestcanada.com canadapharmacyonline legit
canadian pharmacy no prescription: cheapest pharmacy for prescriptions without insurance – cheapest pharmacy for prescriptions without insurance
http://36and6health.com/# mail order pharmacy no prescription
lisinopril 10mg lisinopril 80mg tablet zestril 5mg
neurontin pills for sale neurontin tablets no script purchase neurontin canada
п»їcytotec pills online: buy cytotec pills – Misoprostol 200 mg buy online
order cheap propecia: buying cheap propecia without rx – get generic propecia without rx
http://gabapentin.club/# generic neurontin 300 mg
where can i buy neurontin online neurontin oral neurontin india