当前位置:网站首页>request对象对请求体,请求头参数的解析
request对象对请求体,请求头参数的解析
2022-07-07 07:17:00 【chuntian_tester】
1.请求体参数解析:
1.1 GET请求
1.1.1 请求url中/?xxx&xxx格式为查询字符串参数,通过request.GET获取请求参数
1.1.2 请求url中/xxx/2/xxx格式为路径参数,通过request.GET获取
1.1.3 url中xx/?name=aa&age=19&name=bb,通过request.GET获取,若想获取所有name参数,通过getlist('key1')获取相同key的多个值,返回list类型
1.2 POS请求
1.2.1 json格式请求体参数
json格式的参数会存放在body中,一般为bytes字节类型,使用json.loads(request.body)处理后提取参数
1.2.2 www-form-urlencoded格式参数
一般在前端通过表单录入的参数就是www-form-urlencoded类型 ,通过request.POST获取
1.2.3 file文件类型参数
1.2.3.1 通过form-data中的file类型参数
content_type类型为multipart/form-data,参数从request.body中获取
1.2.3.2 通过binary中的file类型参数
纯文件,都用request.body获取
2.请求头参数解析:
2.1 request.headers['key']或者request.headers.get('key')获取
2.2 request.META['HTTP_AUTHORIZATION']获取
请求头参数会被转化为:HTTP_参数名大写,如果参数名中有‘-’符号,会自动转化为‘_'
边栏推荐
- C# Socke 服务器,客户端,UDP
- 运用tensorflow中的keras搭建卷积神经网络
- Three years after graduation
- “十二星座女神降临”全新活动推出
- [bw16 application] Anxin can realize mqtt communication with bw16 module / development board at instruction
- MySQL can connect locally through localhost or 127, but cannot connect through intranet IP (for example, Navicat connection reports an error of 1045 access denied for use...)
- The combination of over clause and aggregate function in SQL Server
- JS逆向教程第一发
- Selenium+bs4 parsing +mysql capturing BiliBili Tarot data
- CDZSC_2022寒假个人训练赛21级(1)
猜你喜欢
How to use clipboard JS library implements copy and cut function
Dynamics 365online applicationuser creation method change
Pytest learning - dayone
农牧业未来发展蓝图--垂直农业+人造肉
EXT2 file system
Arthas simple instructions
Basic chapter: take you through notes
iNFTnews | 时尚品牌将以什么方式进入元宇宙?
Applet sliding, clicking and switching simple UI
【frida实战】“一行”代码教你获取WeGame平台中所有的lua脚本
随机推荐
Win10安装VS2015
Before joining the chain home, I made a competitive product analysis for myself
Database multi table Association query problem
Natapp intranet penetration
2020CCPC威海 J - Steins;Game (sg函数、线性基)
Future development blueprint of agriculture and animal husbandry -- vertical agriculture + artificial meat
【无标题】
# Arthas 简单使用说明
运用tensorflow中的keras搭建卷积神经网络
Addition, deletion, modification and query of ThinkPHP database
The industrial chain of consumer Internet is actually very short. It only undertakes the role of docking and matchmaking between upstream and downstream platforms
sql 里面使用中文字符判断有问题,哪位遇到过?比如value<>`无`
How to become a senior digital IC Design Engineer (5-2) theory: ULP low power design technology (Part 1)
Create an int type array with a length of 6. The values of the array elements are required to be between 1-30 and are assigned randomly. At the same time, the values of the required elements are diffe
[original] what is the core of programmer team management?
[Frida practice] "one line" code teaches you to obtain all Lua scripts in wegame platform
Flex flexible layout
字节跳动 Kitex 在森马电商场景的落地实践
Application of C # XML
Qualifying 3