?
本文檔使用 php中文網(wǎng)手冊 發(fā)布
Content-Type
實體頭用于指示所述媒體類型的資源的。
作為響應,Content-Type
標題告訴客戶實際返回的內(nèi)容的內(nèi)容類型。瀏覽器在某些情況下會執(zhí)行 MIME 嗅探,并不一定會遵循此標頭的值; 為了防止這種行為,X-Content-Type-Options
可以將標題設置為nosniff
。
在請求(例如POST
或PUT
)中,客戶端通知服務器實際發(fā)送了什么類型的數(shù)據(jù)。
Header type | Entity header |
---|---|
Forbidden header name | no |
CORS-safelisted response-header | yes |
Content-Type: text/html; charset=utf-8Content-Type: multipart/form-data; boundary=something
media-type
資源的 MIME 類型或 data.charset 字符編碼標準。邊界對于多部分實體,boundary
指令是必需的,它由1到70個字符組成,這些字符通過電子郵件網(wǎng)關已知非常強大,并且不以空格結(jié)尾。它用于封裝消息多個部分的邊界。
Content-Type
在 HTML 表單中在POST
來自 HTML 表單提交Content-Type
的請求中,請求的內(nèi)容由元素enctype
上的屬性指定<form>
。
<form action="/" method="post" enctype="multipart/form-data"> <input type="text" name="description" value="some text"> <input type="file" name="myFile"> <button type="submit">Submit</button> </form>
這個請求看起來像這樣(這里省略了一些有趣的標題):
POST /foo HTTP/1.1Content-Length: 68137Content-Type: multipart/form-data; boundary=---------------------------974767299852498929531610575---------------------------974767299852498929531610575Content-Disposition: form-data; name="description" some text---------------------------974767299852498929531610575Content-Disposition: form-data; name="myFile"; filename="foo.txt" Content-Type: text/plain (content of the uploaded file foo.txt)---------------------------974767299852498929531610575
Specification | Title |
---|---|
RFC 7233, section 4.1: Content-Type in multipart | Hypertext Transfer Protocol (HTTP/1.1): Range Requests |
RFC 7231, section 3.1.1.5: Content-Type | Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content |
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic Support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
Feature | Android | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic Support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |