(HTTP)常见请求头、响应头、ContentType整理
请求头
| 请求头 | 说明 |
|---|
| Accept | 浏览器支持的 MIME 媒体类型 |
| Accept-Charset | 用于指定客户端接受的字符集 |
| Accept-Encoding | 用于指定可接受的内容编码,如gzip/deflate。 |
| Accept-Language | 用于指定一种自然语言,如zh-CN |
| Host | 用于指定被请求资源的Internet主机和端口号 |
| User-Agent | 客户端将他的操作系统、浏览器和其他属性告诉服务器。 |
| Origin | 告诉服务器请求从哪里发起的,仅包括协议和域名。CORS跨域请求中可以看到response有对应的header,Access-Control-Allow-Origin。 |
| Referer | 请求来源,告诉服务器请求的原始资源的URI,其用于所有类型的请求,并且包括:协议+域名+查询参数。很多抢购服务会用这个做限制,必须通过某个入口来进来才有效。 |
| Cookie | 表示服务端给客户端传的http请求状态,也是多个key=value形式组合,比如登录后的令牌等。 |
| Connection | 当前连接是否保持,如Keep-Alive。 |
| Content-Type | HTTP请求提交的内容类型,一般只有post提交时才需要设置,比如文件上传,表单提交等。用来指定不同格式的请求格式响应信息俗称 MIME 媒体类型。 |
| Date | 请求发送时间 |
| Cache相关 | Etag/Last-Modified/(max-age/Expires) |
响应头
| 响应头 | 说明 |
|---|
| Server | 使用的服务器名称,如Nginx/Apache。 |
| Content-Type | 用来指明发送给接收者的实体正文的 MIME 媒体类型 |
| Content-Encoding | 与请求报头Accept-Encoding对应,告诉浏览器服务端采用的是什么压缩编码。 |
| Content-Language | 描述了资源使用的自然语言,与Accept-Language对应。 |
| Content-Length | 指明实体正文的长度,用以字节方式存储的十进制数字来表示。 |
| Keep-Alive | 保持连接的时间,如Keep-Alive:timerout=5,max=120。 |
| Allow | 服务器支持哪些请求方法 |
| Access-Control-Allow-Origin | 服务端指定哪些站点可以参与跨站资源共享 |
| Location | 表示客户应当到哪里去获取资源,一般同时设置状态代码为3xx重定向。 |
| Transfer-Encoding | chunked 表示输出的内容长度不能确定,静态网页一般没,基本出现在动态网页里面。 |
| Refresh | 是否刷新 |
| Accept-Ranges | 响应的 HTTP 标头是由服务器使用以通告其支持部分请求的标志物。此字段的值表示可用于定义范围的单位。 |
| Date | 请求发送的日期和时间 |
| Cache相关 | Etag/Last-Modified/(max-age/Expires) |
ContentType
| 文件类型 | ContentType |
|---|
| 7z | application/octet-stream |
| adb | text/x-adasrc |
| avi | video/x-msvideo |
| bmp | image/bmp |
| bak | application/x-trash |
| bin | application/octet-stream |
| c | text/x-csrc |
| cpp | text/x-c++src |
| class | application/x-java |
| css | text/css |
| csv | text/csv |
| csv | application/vnd.ms-excel |
| conf | text/plain |
| conf | application/octet-stream |
| docx | application/vnd.openxmlformats-officedocument.wordprocessingml.document |
| doc | application/msword |
| dv | video/dv |
| dwg | image/vnd.dwg |
| exe | application/x-msdownload |
| fig | image/x-xfig |
| flac | audio/x-flac |
| flv | video/x-flv |
| gif | image/gif |
| html | text/html |
| ico | image/x-icon |
| iso | application/x-cd-image |
| iso9660 | application/x-cd-image |
| ini | text/plain |
| ini | application/octet-stream |
| jpg | image/jpeg |
| js | application/javascript |
| js | text/javascript |
| jsonp | application/jsonp |
| json | application/json |
| log | application/octet-stream |
| mpp | application/vnd.ms-project |
| m4a | audio/mp4 |
| mkv | video/x-matroska |
| mp3 | audio/mpeg |
| mp4 | video/mp4 |
| m4v | video/mp4 |
| moov | video/quicktime |
| mov | video/quicktime |
| movie | video/x-sgi-movie |
| md | text/plain |
| md | application/x-genesis-rom |
| nbm | application/octet-stream |
| obj | application/x-tgif |
| ocl | text/x-ocl |
| ogg | video/x-theora+ogg |
| oga | audio/ogg |
| ppk | text/plain |
| ppk | application/octet-stream |
| php | application/x-php |
| py | text/x-python |
| png | image/png |
| pptx | application/vnd.openxmlformats-officedocument.presentationml.presentation |
| ppt | application/vnd.ms-powerpoint |
| pdf | application/pdf |
| reg | text/x-ms-regedit |
| src | application/x-wais-source |
| so | application/x-sharedlib |
| svg | image/svg+xml |
| sub | text/x-subviewer |
| sql | application/octet-stream |
| sql | text/x-sql |
| tar.gz | application/x-compressed-tar |
| theme | application/x-theme |
| tgz | application/x-compressed-tar |
| ttf | application/x-font-ttf |
| tif | image/tiff |
| txt | text/plain |
| uri | text/x-uri |
| url | text/x-uri |
| wav | audio/x-wav |
| wbmp | image/vnd.wap.wbmp |
| webm | video/webm |
| wmv | video/x-ms-wmv |
| xls | application/vnd.ms-excel |
| xlsx | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
| xhtml | application/xhtml+xml |
| xml | text/xml |
| xml | application/xml |
| xml | application/opensearchdescription+xml |
| xmind | application/octet-stream |
| yml | text/plain |
| yml | application/octet-stream |
| zip | application/x-zip-compressed |
| zip | application/zip |
| binary | application/octet-stream |
| defaultformdata | application/x-www-form-urlencoded |
| fileformdata | multipart/form-data |