woodongwong / notes

4 stars 0 forks source link

记一次服务端无法获取HTTP请求头中带有下划线的字段问题 #51

Open woodongwong opened 4 years ago

woodongwong commented 4 years ago

起因

最近在对接友盟U-Push时,回执接口请求签名验证字段是在Header中,字段为带有下划线的umeng_token,但我在回执接口中始终拿不到umeng_token

图片

解决方法

在Nginx中,默认会删除带下划线的HTTP头信息,这样做是为了防止将头信息映射到CGI变量时出现歧义。将underscores_in_headers设为on,Nginx将不再对此处理。

If you do not explicitly set underscores_in_headers on;, NGINX will silently drop HTTP headers with underscores (which are perfectly valid according to the HTTP standard). This is done in order to prevent ambiguities when mapping headers to CGI variables as both dashes and underscores are mapped to underscores during that process.

参考