Django Python 获取请求头信息Content-Range的方法


Posted in Python onAugust 06, 2019

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的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持三水点靠木。

Python 相关文章推荐
Python运行的17个时新手常见错误小结
Aug 07 Python
Python中random模块用法实例分析
May 19 Python
python xml.etree.ElementTree遍历xml所有节点实例详解
Dec 04 Python
Django视图和URL配置详解
Jan 31 Python
python opencv实现运动检测
Jul 10 Python
浅谈python中拼接路径os.path.join斜杠的问题
Oct 23 Python
对python3新增的byte类型详解
Dec 04 Python
python实现关闭第三方窗口的方法
Jun 28 Python
python树的同构学习笔记
Sep 14 Python
pandas和spark dataframe互相转换实例详解
Feb 18 Python
浅谈pytorch torch.backends.cudnn设置作用
Feb 20 Python
next在python中返回迭代器的实例方法
Dec 15 Python
pytorch中如何使用DataLoader对数据集进行批处理的方法
Aug 06 #Python
django foreignkey外键使用的例子 相当于left join
Aug 06 #Python
Python Django简单实现session登录注销过程详解
Aug 06 #Python
Django框架中序列化和反序列化的例子
Aug 06 #Python
python异常触发及自定义异常类解析
Aug 06 #Python
Python DataFrame一列拆成多列以及一行拆成多行
Aug 06 #Python
Django中reverse反转并且传递参数的方法
Aug 06 #Python
You might like
关于PHP结束标签的使用细节探讨及联想
2013/03/04 PHP
解析php mysql 事务处理回滚操作(附实例)
2013/08/05 PHP
XML+XSL 与 HTML 两种方案的结合
2007/04/22 Javascript
javascript中的数字与字符串相加实例分析
2011/08/14 Javascript
浮动的div自适应居中显示的js代码
2013/12/23 Javascript
轻松创建nodejs服务器(1):一个简单nodejs服务器例子
2014/12/18 NodeJs
JavaScript实现跨浏览器的添加及删除事件绑定函数实例
2015/08/04 Javascript
js将滚动条滚动到指定位置的简单实现方法
2016/06/25 Javascript
基于JS实现类似支付宝支付密码输入框
2016/09/02 Javascript
AngularJS学习第一篇 AngularJS基础知识
2017/02/13 Javascript
JavaScript数组基于交换的排序示例【冒泡排序】
2018/07/21 Javascript
js回文数的4种判断方法示例
2019/06/04 Javascript
Angular8路由守卫原理和使用方法
2019/08/29 Javascript
JavaScript原型式继承实现方法
2019/11/06 Javascript
Python加载带有注释的Json文件实例
2018/05/23 Python
Python 运行 shell 获取输出结果的实例
2019/01/07 Python
python twilio模块实现发送手机短信功能
2019/08/02 Python
opencv 查找连通区域 最大面积实例
2020/06/04 Python
基于Python实现体育彩票选号器功能代码实例
2020/09/16 Python
Pycharm编辑器功能之代码折叠效果的实现代码
2020/10/15 Python
基于Django集成CAS实现流程详解
2020/11/28 Python
详解pycharm自动import所需的库的操作方法
2020/11/30 Python
html5指南-4.使用Geolocation实现定位功能
2013/01/07 HTML / CSS
使用纯HTML5编写一款网页上的时钟的代码分享
2015/11/16 HTML / CSS
详解html5 canvas 微信海报分享(个人爬坑)
2018/01/12 HTML / CSS
新秀丽拉杆箱美国官方网站:Samsonite美国
2016/07/25 全球购物
香港礼品网站:GiftU eshop
2017/09/01 全球购物
西雅图电动自行车公司:Rad Power Bikes
2020/02/02 全球购物
Sony C++笔试题
2013/03/10 面试题
英文求职信写作小建议
2014/02/16 职场文书
《大海那边》教学反思
2014/04/09 职场文书
老公给老婆的保证书
2014/04/28 职场文书
学校门卫岗位职责范本
2014/06/30 职场文书
施工安全责任书范本
2014/07/24 职场文书
街道社区活动报告
2015/02/05 职场文书
SpringBoot+Vue+JWT的前后端分离登录认证详细步骤
2021/09/25 Java/Android