Django Python 获取请求头信息Content-Range
来源:互联网 发布:反恐精英刀具可以优化 编辑:程序博客网 时间:2024/06/05 16:05
request请求头信息的键会加上HTTP_转换成大写存到request.META中
因此你只需要
content_range = request.META['HTTP_CONTENT_RANGE']
这样就可以获取到Content-Range的信息。
django官网的解释:
A standard Python dictionary containing all available HTTP headers. Available headers depend on the client and server, but here are some examples:
CONTENT_LENGTH
– The length of the request body (as a string).CONTENT_TYPE
– The MIME type of the request body.HTTP_ACCEPT
– Acceptable content types for the response.HTTP_ACCEPT_ENCODING
– Acceptable encodings for the response.HTTP_ACCEPT_LANGUAGE
– Acceptable languages for the response.HTTP_HOST
– The HTTP Host header sent by the client.HTTP_REFERER
– The referring page, if any.HTTP_USER_AGENT
– The client’s user-agent string.QUERY_STRING
– The query string, as a single (unparsed) string.REMOTE_ADDR
– The IP address of the client.REMOTE_HOST
– The hostname of the client.REMOTE_USER
– The user authenticated by the Web server, if any.REQUEST_METHOD
– A string such as"GET"
or"POST"
.SERVER_NAME
– The hostname of the server.SERVER_PORT
– The port of the server (as a string).
With the exception of CONTENT_LENGTH
and CONTENT_TYPE
, as given above, any HTTP headers in the request are converted to META
keys by converting all characters to uppercase, replacing any hyphens with underscores and adding an HTTP_
prefix to the name. So, for example, a header called X-Bender
would be mapped to the META
key HTTP_X_BENDER
.
很多同学在找Content-Range的时候发现文档中没有这个,所以以为不支持这个,一直再找。百度 Google什么的
但是其实这个文档只是列出的其中一部分,而且他们没细心的读A standard Python dictionary containing all available HTTP headers,这一句,同时上面的也只是一部分例子,因此在看文档的时候,希望同学们能细心一点!
- Django Python 获取请求头信息Content-Range
- Http头 Range、Content-Range
- Http头 Range、Content-Range
- 演示获取请求头信息
- Http协议头 Range、Content-Range分析
- Http头 Range、Content-Range【断点续传】
- Range和Content-Range实体头
- Extjs中加入Content-Type HTTP请求头信息
- url get请求头信息获取
- php获取请求返回头信息
- 获取请求头杂七杂八的信息
- Servlet--获取Http协议请求头信息
- 从请求的头获取信息
- JAVA获取POST请求的请求头信息
- Http Range请求头格式
- django一些头信息
- AJAX请求头Content-type
- AJAX请求头Content-type
- 概率p输出1,概率1-p输出0,等概率输出0和1
- PDO数据访问抽象层
- 使用IDEA和gradle搭建Spring MVC和MyBatis开发环境
- libevent源码深度剖析七
- Hibernate工具类之获取SessionFactory
- Django Python 获取请求头信息Content-Range
- Leetcode 212. Word Search II
- iOS 自动布局框架 Masonry
- Trafodion 如何实现分页
- No subscribers registered for event class
- 算法设计与分析(3)-- Median of Two Sorted Arrays(难度:hard)
- 一个菜鸟的IT路
- tableView 分割线宽度没占据整个屏幕的宽度
- libevent源码深度剖析八