这几天之所以去了解这个,就是之前埋下的雷,自定义名称用了下划线_,前两天莫名其妙犯病一直获取不了,以为是被浏览器或是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-开头也没问题,但并不建议你这样干。
buy priligy in the us Overall, the 5 year survival rate is 50 for those who respond to therapy for GVHD and 30 for those with no or an incomplete response
Live Coin Watch I truly appreciate your technique of writing a blog. I added it to my bookmark site list and will
Real Estate Hi there to all, for the reason that I am genuinely keen of reading this website’s post to be updated on a regular basis. It carries pleasant stuff.
Real Estate This is really interesting, You’re a very skilled blogger. I’ve joined your feed and look forward to seeking more of your magnificent post. Also, I’ve shared your site in my social networks!
Ny weekly This was beautiful Admin. Thank you for your reflections.
Business dicker I very delighted to find this internet site on bing, just what I was searching for as well saved to fav
More casino news Next up in 5 “Pechanga and its leadership remained the forerunners of implementing and executing safety protocols,” said Kimberly Adams, president of Visit Temecula Valley. Raving CEO & Owner Deana Scott shared, “Raving NEXT has always been hosted by a tribal gaming property. However, this is the first time that the Casino Marketing & Technology and Host & PD conference will be held outside of Nevada, at an Indian gaming property! What an opportunity for our international, racino and commercial operators to experience our conference at a world-class Tribal resort.” Chargers Legends Golf Tournament 2023 at Journey at Pechanga MyNewsLA Pechanga expects to complete several other improvements by the end of the year, including a new spa, new event space, and two new restaurants.
http://adriapension.co.kr/bbs/board.php?bo_table=free&wr_id=33976
The Bet365 Casino New Jersey gambling site will impress many of the NJ players. And there is a good reason for that. First of all, the Bet365 Casino site offers a diverse selection of casino games. You can choose from different types of gambling games to enjoy at home or on the go via the app. These include online slots and also table games such as roulette, blackjack, and baccarat. A slight disappointment will be the lack of any live dealer games, though. For real money mobile gaming, Bet365 provides free native apps. Available for iPhone and Android devices, the Bet365 app is easy to install and use. Registered players can enter the same account credentials and continue betting from anywhere within state borders. The only poker on offer at bet365 is carnival-style; play against the dealer games like Heads up Poker and Casino Hold’em. Actual Live poker is not on offer. This is interesting because Bet365 is an online leader in poker in markets all around the world.