简体   繁体   English

在 web.py 中获取自定义 HTTP 请求标头?

[英]Getting custom HTTP request headers in web.py?

I know that, with web.ctx.env, I can get a lot of information that comes from the headers -- but only the standard headers.我知道,通过 web.ctx.env,我可以获得大量来自标头的信息——但仅限于标准标头。 Is it possible to obtain all HTTP request headers from within a GET or POST method in web.py?是否可以从 web.py 中的 GET 或 POST 方法中获取所有 HTTP 请求标头?

Are you sure that it has only standard headers?您确定它只有标准标题吗? Cos I'm using it to check web.ctx.env.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest' which is not in the list on that page.因为我正在使用它来检查web.ctx.env.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest' ,它不在该页面的列表中。 I also get values of HTTP_X_FILE_NAME and HTTP_X_FILE_TYPE headers that I set in xhr like this: xhr.setRequestHeader( "X-File-Type", file.type );我还得到了我在 xhr 中设置的HTTP_X_FILE_NAMEHTTP_X_FILE_TYPE标头的值,如下所示: xhr.setRequestHeader( "X-File-Type", file.type ); . .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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