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中使用Boolean操作符做真值测试实例
Jan 30 Python
使用Python来编写HTTP服务器的超级指南
Feb 18 Python
分析Python中设计模式之Decorator装饰器模式的要点
Mar 02 Python
python中解析json格式文件的方法示例
May 03 Python
Python实现调度算法代码详解
Dec 01 Python
numpy.delete删除一列或多列的方法
Apr 03 Python
Pandas标记删除重复记录的方法
Apr 08 Python
python3+PyQt5 创建多线程网络应用-TCP客户端和TCP服务器实例
Jun 17 Python
Django如何使用第三方服务发送电子邮件
Aug 14 Python
2021年的Python 时间轴和即将推出的功能详解
Jul 27 Python
Python unittest装饰器实现原理及代码
Sep 08 Python
VSCode中autopep8无法运行问题解决方案(提示Error: Command failed,usage)
Mar 02 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原理的opcodes(操作码)
2010/10/26 PHP
destoon常用的安全设置概述
2014/06/21 PHP
jQuery创建插件的代码分析
2011/04/14 Javascript
利用ajaxfileupload插件实现文件上传无刷新的具体方法
2013/06/08 Javascript
兼容主流浏览器的jQuery+CSS 实现遮罩层的简单代码
2014/10/14 Javascript
原生js实现移动开发轮播图、相册滑动特效
2015/04/17 Javascript
JS实现跟随鼠标的链接文字提示框效果
2015/08/06 Javascript
js图片轮播特效代码分享
2015/09/07 Javascript
jquery实现的判断倒计时是否结束代码
2016/02/05 Javascript
使用JavaScript实现弹出层效果的简单实例
2016/05/31 Javascript
javascript url几种编码方式详解
2016/06/06 Javascript
jquery ajax后台返回list,前台用jquery遍历list的实现
2016/10/30 Javascript
AngularJS constant和value区别详解
2017/02/28 Javascript
jQuery简单绑定单个事件的方法示例
2017/06/10 jQuery
详解vue2.0的Element UI的表格table列时间戳格式化
2017/06/13 Javascript
JS实现面向对象继承的5种方式分析
2018/07/21 Javascript
小程序实现分类页
2019/07/12 Javascript
js对象简介与基本用法示例
2020/03/13 Javascript
vue element-ui中table合计指定列求和实例
2020/11/02 Javascript
js闭包和垃圾回收机制示例详解
2021/03/01 Javascript
[02:50]2014DOTA2 TI预选赛预选赛 大神专访第一弹!
2014/05/21 DOTA
python的常见命令注入威胁
2013/02/18 Python
解析Python中的生成器及其与迭代器的差异
2016/06/20 Python
Python二进制串转换为通用字符串的方法
2018/07/23 Python
解析python的局部变量和全局变量
2019/08/15 Python
python输出pdf文档的实例
2020/02/13 Python
Django配置跨域并开发测试接口
2020/11/04 Python
老生常谈CSS中的长度单位
2016/06/27 HTML / CSS
John Varvatos官方网站:设计师男士时装
2017/02/08 全球购物
亿阳信通股份有限公司C#笔试题
2016/12/06 面试题
动物科学专业求职信
2014/07/27 职场文书
庆六一开幕词
2015/01/29 职场文书
pycharm2021激活码使用教程(永久激活亲测可用)
2021/03/30 Python
python实现监听键盘
2021/04/26 Python
python基础之类属性和实例属性
2021/10/24 Python
使用CSS连接数据库的方式
2022/02/28 HTML / CSS