简体   繁体   中英

Python Bottle rest headers not working with underscore

I am facing issues for rest headers with underscore, not getting the rest headers value while i am printing them.

Did someone have any idea of how I could make this work ?

Thanks!

You shouldn't use underscores in header names, use only dashes as separators.

Mainstream web servers such as Apache and nginx, plus some Python WSGI servers/frameworks will throw away headers with underscores to avoid header spoofing.

Imagine you have a header:

My-Header: value

This in CGI/WSGI gets converted to variable:

HTTP_MY_HEADER: value

when passed to application.

The problem is that a header:

My_Header: value

also maps to the same.

The danger here is that a client could use one, and something between such as a proxy could deliberately set the other to try and take precedence, overwriting the original when the server/application processes it.

As this is a potential security issue, servers are only allowing headers with alphanumerics and dashes to pass through now and anything else is discarded.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM