这几天之所以去了解这个,就是之前埋下的雷,自定义名称用了下划线_,前两天莫名其妙犯病一直获取不了,以为是被浏览器或是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-开头也没问题,但并不建议你这样干。
http://prednisoned.online/# prednisone in canada
neurontin 800 mg cost: buy neurontin online – neurontin pills for sale
prednisone 7.5 mg prednisone prescription prednisone cost
amoxicillin pharmacy price: amoxicillin discount – amoxicillin buy canada
price of neurontin how to get neurontin cheap neurontin 600mg
http://prednisoned.online/# can i buy prednisone online without a prescription
prednisone 40mg: can i purchase prednisone without a prescription – 20 mg of prednisone
canadian pharmacy ltd: northwest pharmacy canada – canadian drug
https://pharmnoprescription.icu/# mexican pharmacies no prescription
canadian prescription drugstore review: non prescription pharmacy – online pharmacies no prescription
no prescription needed buying drugs without prescription best no prescription online pharmacies
http://pharmnoprescription.icu/# online pharmacy without a prescription
reliable canadian pharmacy canadian drugstore online recommended canadian pharmacies
canadian drugstore online: canadian pharmacy 24h com safe – legit canadian online pharmacy
https://pharmindia.online/# best india pharmacy
canadian pharmacy 24 com: best canadian online pharmacy – legal to buy prescription drugs from canada
http://pharmworld.store/# canadian pharmacy coupon
canada online prescription: online no prescription pharmacy – online doctor prescription canada
http://pharmmexico.online/# buying from online mexican pharmacy
buying prescription drugs online canada online meds no prescription online pharmacy without prescription
medicine in mexico pharmacies mexican pharmacy pharmacies in mexico that ship to usa
https://pharmindia.online/# best india pharmacy
canadian pharmacy without prescription: canada online pharmacy no prescription – pharmacy no prescription required
https://pharmcanada.shop/# legitimate canadian online pharmacies
canadian pharmacy world coupon code pharm world prescription drugs online
п»їonline pharmacy no prescription needed pharmacies without prescriptions mexican prescription drugs online
https://pharmnoprescription.icu/# canadian pharmacy no prescription required
indian pharmacy paypal: best india pharmacy – buy medicines online in india
online drugs without prescription best non prescription online pharmacy non prescription online pharmacy
https://pharmcanada.shop/# northwest canadian pharmacy
canadadrugpharmacy com best rated canadian pharmacy canadian compounding pharmacy
canada rx pharmacy: canadian pharmacy ed medications – canadian medications
buy drugs from canada: medication canadian pharmacy – best canadian online pharmacy
http://pharmnoprescription.icu/# online medication no prescription
canadian pharmacies comparison: northern pharmacy canada – canadian drugstore online
reputable indian online pharmacy indian pharmacy indian pharmacies safe
canadian pharmacy: best online canadian pharmacy – best canadian pharmacy online
canadian pharmacy no prescription needed pharmacy without prescription uk pharmacy no prescription
http://pharmnoprescription.icu/# buy prescription drugs on line
https://pharmmexico.online/# п»їbest mexican online pharmacies
buying from online mexican pharmacy: mexican border pharmacies shipping to usa – mexico drug stores pharmacies
http://pharmworld.store/# us pharmacy no prescription
trusted canadian pharmacy onlinecanadianpharmacy pharmacy rx world canada
my canadian pharmacy rx canadian king pharmacy canadian pharmacy 24
online medication without prescription: prescription meds from canada – online pharmacy not requiring prescription
canadian prescription pharmacy: pharm world – online pharmacy discount code
http://pharmnoprescription.icu/# how to buy prescriptions from canada safely
Levitra 10 mg buy online Buy generic Levitra online Levitra tablet price
https://cenforce.pro/# Purchase Cenforce Online
http://kamagra.win/# buy kamagra online usa