在響應(yīng)中,Content-Type標(biāo)頭告訴客戶端實(shí)際返回的內(nèi)容的內(nèi)容類(lèi)型。瀏覽器會(huì)在某些情況下進(jìn)行MIME查找,并不一定遵循此標(biāo)題的值; 為了防止這種行為,可以將標(biāo)題 X-Content-Type-Options 設(shè)置為 nosniff。
在請(qǐng)求中 (如POST 或 PUT),客戶端告訴服務(wù)器實(shí)際發(fā)送的數(shù)據(jù)類(lèi)型。
語(yǔ)法:
Content-Type: text/html; charset=utf-8Content-Type: multipart/form-data; boundary=something
指令:
media-type
資源或數(shù)據(jù)的 MIME type 。
charset
字符編碼標(biāo)準(zhǔn)。
boundary
對(duì)于多部分實(shí)體,boundary 是必需的,其包括來(lái)自一組字符的1到70個(gè)字符,已知通過(guò)電子郵件網(wǎng)關(guān)是非常健壯的,而不是以空白結(jié)尾。它用于封裝消息的多個(gè)部分的邊界。
例子
Content-Type 在HTML表單中
在通過(guò)HTML form提交生成的POST請(qǐng)求中,請(qǐng)求頭的Content-Type由 form 元素上的enctype屬性指定
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
請(qǐng)求頭看起來(lái)像這樣(在這里省略了一些 headers):
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
以上就是Content-Type作用是什么?的詳細(xì)內(nèi)容,PHP教程
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。
|
新聞熱點(diǎn)
疑難解答
圖片精選