content type 介绍
本篇介绍以html表单提交数据为例,讲述content-type头
<!DOCTYPE html>
<html lang="en"> <head> <meta charset="UTF-8"> <title>测试表单提交Post</title> </head> <body> <form action="post.php" method="post"> <input type="text" name='username'> <input type="text" name='password'> <input type="submit"> </form> </body> </html>
这种最常见的表单,它的请求头为:
POST /test/httpPost/post.php HTTP/1.1
Host: localhost
Connection: keep-alive
Content-Length: 27
Cache-Control: max-age=0
Origin: http://localhost
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
Referer: http://localhost/test/httpPost/index.html
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.8
Cookie: pgv_pvi=8193968128
请求体:
username=zzzz&password=tttt
这里需要注意的是,请求体里的值是经过url encode的
另一种比较复杂的http请求是这样的
<!DOCTYPE html>
<html lang="en"> <head> <meta charset="UTF-8"> <title>测试表单提交Post</title> </head> <body> <form action="post.php" method="post" enctype="multipart/form-data"> <input type="text" name='username'> <input type="text" name='password'> <input type="file" name='picture'> <input type="submit"> </form> </body> </html>
申明了content-type的值为multipart/form-data
这种http post请求头为:
POST /test/httpPost/post.php HTTP/1.1Host: localhost
Connection: keep-alive
Origin: http://localhost
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36
Content-Type: multipart/form-data; boundary=—-WebKitFormBoundaryo8HMWnZkFmHAvcTX声明为这种类型时,后面的boundary参数指定每个参数之间的分隔符
请求体为:
——WebKitFormBoundaryo8HMWnZkFmHAvcTX
Content-Disposition: form-data; name=”username”aaa
——WebKitFormBoundaryo8HMWnZkFmHAvcTX
Content-Disposition: form-data; name=”password”bbb
——WebKitFormBoundaryo8HMWnZkFmHAvcTX
Content-Disposition: form-data; name=”picture”; filename=”1488794518kqnZP.jpg”
Content-Type: image/jpeg——WebKitFormBoundaryo8HMWnZkFmHAvcTX–注意这时候的值没有经过url encode
转载于:https://www.cnblogs.com/amyleell/p/9119796.html
content type 介绍相关推荐
- restTemplate http请求报错:no suitable HttpMessageConverter found for response type and content type
报错信息: org.springframework.web.client.UnknownContentTypeException: Could not extract response: no sui ...
- Posted content type isn't multipart/form-data
版权声明:欢迎转载,请注明沉默王二原创. https://blog.csdn.net/qing_gee/article/details/48712507 在有文件上传的表单提交过程中,搞不好就会报Po ...
- Maven报错解决:Element 'dependency' cannot have character [children], because the type's content type is
在用maven的时候遇到报错: Element 'dependency' cannot have character [children], because the type's content ty ...
- 用VS向SharePoint中部署添加List 并指定应用的Content Type
在SharePoint Project中添加相应的Item,完全用界面的形式向EricSunArticlesList中添加好对应的Column,之后用Feature将List添加到SharePoint ...
- Spring Boot——[Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported]解决方案
问题描述 2020-02-13 19:32:04.322 WARN 109508 --- [p-nio-80-exec-4] .m.m.a.ExceptionHandlerExceptionResol ...
- : Content type 'text/plain;charset=UTF-8' not supported
: Content type 'text/plain;charset=UTF-8' not supported
- eclipse 设置 content type 编码格式
前言 Eclipse Version: 2019-12 (4.14.0) 操作 打开Preferences.菜单路径为:Window–> Preferences 在搜索框中输入:content ...
- sendData to ABAP backend via multiple form content type
Created by Jerry Wang, last modified on Aug 20, 2014 使用multipart/form-data的content type通过Javascript向 ...
- 阿里云存储OSS中设置上传文件content type
阿里云存储OSS中设置上传文件ContentType 如果你使用浏览器上传文件,则浏览器会自动在header中设置正确地content type,然后对文件的访问会得到正确地回应. 如果采用编程的方式 ...
最新文章
- Transform(CTM,Translate,Rotate,Scale)
- 6/5 补瓷砖,购浴缸
- (转)Inno Setup入门(二十一)——Inno Setup类参考(7)
- 2018年Github最受欢迎机器学习语言Python稳坐冠军,numpy、scipy是最受欢迎软件包...
- kafka+zookeeper安装配置
- [转]web测试技术经典案例
- JavaScript AppendChild 引发的思考
- 基于华为云的Django网站部署
- zabbix JMX监控 tomcat
- python中if嵌套语句的作用_讲解Python中if语句的嵌套用法
- 一个网站大概多少钱_建一个外贸网站大概需要多少钱?角点科技总结建外贸网站的费用...
- CSU 1803 2016(数论)
- 用Winhex手工定位NTFS文件系统下的文件
- Golang在Linux环境下的POSIX风格socket编程
- 磁盘调度算法课程设计(附源代码)
- VS、C#配置R语言开发环境
- EPOLLONESHOT及其引发的EPOLL在ET能被多次触发吗?
- DXperience-6.2.4 破解
- STVD cpstm8 miss } in struct/union definition
- iphone里如何实现像图片浏览那样的自动隐藏和导航条和工具栏
热门文章
- poi读取Excel内容数据
- 病毒与故障:漫谈计算机软件的故障应对
- 在 Java 的反射中,Class.forName 和 ClassLoader 的区别
- 毕业三年,贷款40万创业之后我又做回了程序员
- 图解Linux系统调用
- 假笨说-我是如何走上JVM这条贼船的
- Realm及相关对象——《跟我学Shiro》
- Go: 字符串比较的三种方法
- Android 面试 - compileSdkVersion、minSdkVersion、targetSdkVersion、buildToolsVersion
- “adb”不是内部或外部命令,也不是可运行的程序或批处理文件(Win)与(Mac)——终极解决方案