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检测网页是否有日常链接
Jun 03 Python
Python实现从url中提取域名的几种方法
Sep 26 Python
Python中字符串的格式化方法小结
May 03 Python
Python中使用多进程来实现并行处理的方法小结
Aug 09 Python
Python中单例模式总结
Feb 20 Python
对Python中type打开文件的方式介绍
Apr 28 Python
Python中跳台阶、变态跳台阶与矩形覆盖问题的解决方法
May 19 Python
flask框架中勾子函数的使用详解
Aug 01 Python
浅析Python函数式编程
Oct 06 Python
python读取文件名并改名字的实例
Jan 07 Python
Django 静态文件配置过程详解
Jul 23 Python
Python高级特性 切片 迭代解析
Aug 23 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实现图象锐化代码
2007/06/14 PHP
PHP 采集心得技巧
2009/05/15 PHP
处理(php-cgi.exe - FastCGI 进程超过了配置的请求超时时限)的问题
2013/07/03 PHP
thinkphp文件处理类Dir.class.php的用法分析
2014/12/08 PHP
PHP获取网站中各文章的第一张图片的代码示例
2016/05/20 PHP
PHP与jquery实时显示网站在线人数实例详解
2016/12/02 PHP
如何在Web页面上直接打开、编辑、创建Office文档
2007/03/12 Javascript
基于jquery的has()方法以及与find()方法以及filter()方法的区别详解
2013/04/26 Javascript
如何解决Jquery库及其他库之间的$命名冲突
2013/09/15 Javascript
javascript模拟实现C# String.format函数功能代码
2013/11/25 Javascript
jQuery(js)获取文字宽度(显示长度)示例代码
2013/12/31 Javascript
深入浅析AngularJS中的module(模块)
2016/01/04 Javascript
jQuery实现边框动态效果的实例代码
2016/09/23 Javascript
JS实现字符串转驼峰格式的方法
2016/12/16 Javascript
利用VS Code开发你的第一个AngularJS 2应用程序
2017/12/15 Javascript
如何利用@angular/cli V6.0直接开发PWA应用详解
2018/05/06 Javascript
three.js搭建室内场景教程
2018/12/30 Javascript
JS实现计算小于非负数n的素数的数量算法示例
2019/02/26 Javascript
vue实现微信获取用户信息的方法
2019/03/21 Javascript
jQuery 函数实例分析【函数声明、函数表达式、匿名函数等】
2020/05/19 jQuery
[40:56]2018DOTA2亚洲邀请赛 3.31 小组赛 A组 Liquid vs TNC
2018/04/01 DOTA
Python实现TCP协议下的端口映射功能的脚本程序示例
2016/06/14 Python
Django自定义插件实现网站登录验证码功能
2017/04/19 Python
Python标准库inspect的具体使用方法
2017/12/06 Python
深入浅析Python中list的复制及深拷贝与浅拷贝
2018/09/03 Python
python 日期排序的实例代码
2019/07/11 Python
TobyDeals美国:在电子产品上获得最好的优惠和折扣
2019/08/11 全球购物
策划助理岗位职责
2013/11/18 职场文书
药剂专业学生求职信范文
2013/12/28 职场文书
无房产证房屋转让协议书合同样本
2014/10/18 职场文书
2014年干部作风建设总结
2014/10/23 职场文书
中学校园广播稿
2015/08/18 职场文书
2016公务员年度考核评语
2015/12/01 职场文书
2016年基层党支部书记公开承诺书
2016/03/25 职场文书
教师学期述职自我鉴定
2019/08/16 职场文书
使用pd.merge表连接出现多余行的问题解决
2022/06/16 Python