HTTP 狀態(tài)碼
當(dāng)瀏覽者訪問一個(gè)網(wǎng)頁時(shí),瀏覽者的瀏覽器會(huì)向網(wǎng)頁所在服務(wù)器發(fā)出請(qǐng)求。當(dāng)瀏覽器接收并顯示網(wǎng)頁前,此網(wǎng)頁所在的服務(wù)器會(huì)返回一個(gè)包含 HTTP 狀態(tài)碼的信息頭(server header)用以響應(yīng)瀏覽器的請(qǐng)求。
HTTP 狀態(tài)碼的英文為?HTTP Status Code。。
下面是常見的 HTTP 狀態(tài)碼:
- 200 - 請(qǐng)求成功
- 301 - 資源(網(wǎng)頁等)被永久轉(zhuǎn)移到其它URL
- 404 - 請(qǐng)求的資源(網(wǎng)頁等)不存在
- 500 - 內(nèi)部服務(wù)器錯(cuò)誤
HTTP 狀態(tài)碼分類
HTTP 狀態(tài)碼由三個(gè)十進(jìn)制數(shù)字組成,第一個(gè)十進(jìn)制數(shù)字定義了狀態(tài)碼的類型。響應(yīng)分為五類:信息響應(yīng)(100–199),成功響應(yīng)(200–299),重定向(300–399),客戶端錯(cuò)誤(400–499)和服務(wù)器錯(cuò)誤 (500–599):
分類 | 分類描述 |
---|---|
1** | 信息,服務(wù)器收到請(qǐng)求,需要請(qǐng)求者繼續(xù)執(zhí)行操作 |
2** | 成功,操作被成功接收并處理 |
3** | 重定向,需要進(jìn)一步的操作以完成請(qǐng)求 |
4** | 客戶端錯(cuò)誤,請(qǐng)求包含語法錯(cuò)誤或無法完成請(qǐng)求 |
5** | 服務(wù)器錯(cuò)誤,服務(wù)器在處理請(qǐng)求的過程中發(fā)生了錯(cuò)誤 |
HTTP狀態(tài)碼列表:
狀態(tài)碼 | 狀態(tài)碼英文名稱 | 中文描述 |
---|---|---|
100 | Continue | 繼續(xù)??蛻舳藨?yīng)繼續(xù)其請(qǐng)求 |
101 | Switching Protocols | 切換協(xié)議。服務(wù)器根據(jù)客戶端的請(qǐng)求切換協(xié)議。只能切換到更高級(jí)的協(xié)議,例如,切換到HTTP的新版本協(xié)議 |
200 | OK | 請(qǐng)求成功。一般用于GET與POST請(qǐng)求 |
201 | Created | 已創(chuàng)建。成功請(qǐng)求并創(chuàng)建了新的資源 |
202 | Accepted | 已接受。已經(jīng)接受請(qǐng)求,但未處理完成 |
203 | Non-Authoritative Information | 非授權(quán)信息。請(qǐng)求成功。但返回的meta信息不在原始的服務(wù)器,而是一個(gè)副本 |
204 | No Content | 無內(nèi)容。服務(wù)器成功處理,但未返回內(nèi)容。在未更新網(wǎng)頁的情況下,可確保瀏覽器繼續(xù)顯示當(dāng)前文檔 |
205 | Reset Content | 重置內(nèi)容。服務(wù)器處理成功,用戶終端(例如:瀏覽器)應(yīng)重置文檔視圖。可通過此返回碼清除瀏覽器的表單域 |
206 | Partial Content | 部分內(nèi)容。服務(wù)器成功處理了部分GET請(qǐng)求 |
300 | Multiple Choices | 多種選擇。請(qǐng)求的資源可包括多個(gè)位置,相應(yīng)可返回一個(gè)資源特征與地址的列表用于用戶終端(例如:瀏覽器)選擇 |
301 | Moved Permanently | 永久移動(dòng)。請(qǐng)求的資源已被永久的移動(dòng)到新URI,返回信息會(huì)包括新的URI,瀏覽器會(huì)自動(dòng)定向到新URI。今后任何新的請(qǐng)求都應(yīng)使用新的URI代替 |
302 | Found | 臨時(shí)移動(dòng)。與301類似。但資源只是臨時(shí)被移動(dòng)??蛻舳藨?yīng)繼續(xù)使用原有URI |
303 | See Other | 查看其它地址。與301類似。使用GET和POST請(qǐng)求查看 |
304 | Not Modified | 未修改。所請(qǐng)求的資源未修改,服務(wù)器返回此狀態(tài)碼時(shí),不會(huì)返回任何資源。客戶端通常會(huì)緩存訪問過的資源,通過提供一個(gè)頭信息指出客戶端希望只返回在指定日期之后修改的資源 |
305 | Use Proxy | 使用代理。所請(qǐng)求的資源必須通過代理訪問 |
306 | Unused | 已經(jīng)被廢棄的HTTP狀態(tài)碼 |
307 | Temporary Redirect | 臨時(shí)重定向。與302類似。使用GET請(qǐng)求重定向 |
400 | Bad Request | 客戶端請(qǐng)求的語法錯(cuò)誤,服務(wù)器無法理解 |
401 | Unauthorized | 請(qǐng)求要求用戶的身份認(rèn)證 |
402 | Payment Required | 保留,將來使用 |
403 | Forbidden | 服務(wù)器理解請(qǐng)求客戶端的請(qǐng)求,但是拒絕執(zhí)行此請(qǐng)求 |
404 | Not Found | 服務(wù)器無法根據(jù)客戶端的請(qǐng)求找到資源(網(wǎng)頁)。通過此代碼,網(wǎng)站設(shè)計(jì)人員可設(shè)置"您所請(qǐng)求的資源無法找到"的個(gè)性頁面 |
405 | Method Not Allowed | 客戶端請(qǐng)求中的方法被禁止 |
406 | Not Acceptable | 服務(wù)器無法根據(jù)客戶端請(qǐng)求的內(nèi)容特性完成請(qǐng)求 |
407 | Proxy Authentication Required | 請(qǐng)求要求代理的身份認(rèn)證,與401類似,但請(qǐng)求者應(yīng)當(dāng)使用代理進(jìn)行授權(quán) |
408 | Request Time-out | 服務(wù)器等待客戶端發(fā)送的請(qǐng)求時(shí)間過長,超時(shí) |
409 | Conflict | 服務(wù)器完成客戶端的 PUT 請(qǐng)求時(shí)可能返回此代碼,服務(wù)器處理請(qǐng)求時(shí)發(fā)生了沖突 |
410 | Gone | 客戶端請(qǐng)求的資源已經(jīng)不存在。410不同于404,如果資源以前有現(xiàn)在被永久刪除了可使用410代碼,網(wǎng)站設(shè)計(jì)人員可通過301代碼指定資源的新位置 |
411 | Length Required | 服務(wù)器無法處理客戶端發(fā)送的不帶Content-Length的請(qǐng)求信息 |
412 | Precondition Failed | 客戶端請(qǐng)求信息的先決條件錯(cuò)誤 |
413 | Request Entity Too Large | 由于請(qǐng)求的實(shí)體過大,服務(wù)器無法處理,因此拒絕請(qǐng)求。為防止客戶端的連續(xù)請(qǐng)求,服務(wù)器可能會(huì)關(guān)閉連接。如果只是服務(wù)器暫時(shí)無法處理,則會(huì)包含一個(gè)Retry-After的響應(yīng)信息 |
414 | Request-URI Too Large | 請(qǐng)求的URI過長(URI通常為網(wǎng)址),服務(wù)器無法處理 |
415 | Unsupported Media Type | 服務(wù)器無法處理請(qǐng)求附帶的媒體格式 |
416 | Requested range not satisfiable | 客戶端請(qǐng)求的范圍無效 |
417 | Expectation Failed | 服務(wù)器無法滿足Expect的請(qǐng)求頭信息 |
500 | Internal Server Error | 服務(wù)器內(nèi)部錯(cuò)誤,無法完成請(qǐng)求 |
501 | Not Implemented | 服務(wù)器不支持請(qǐng)求的功能,無法完成請(qǐng)求 |
502 | Bad Gateway | 作為網(wǎng)關(guān)或者代理工作的服務(wù)器嘗試執(zhí)行請(qǐng)求時(shí),從遠(yuǎn)程服務(wù)器接收到了一個(gè)無效的響應(yīng) |
503 | Service Unavailable | 由于超載或系統(tǒng)維護(hù),服務(wù)器暫時(shí)的無法處理客戶端的請(qǐng)求。延時(shí)的長度可包含在服務(wù)器的Retry-After頭信息中 |
504 | Gateway Time-out | 充當(dāng)網(wǎng)關(guān)或代理的服務(wù)器,未及時(shí)從遠(yuǎn)端服務(wù)器獲取請(qǐng)求 |
505 | HTTP Version not supported | 服務(wù)器不支持請(qǐng)求的HTTP協(xié)議的版本,無法完成處理 |
HTTP content-type
Content-Type(內(nèi)容類型),一般是指網(wǎng)頁中存在的 Content-Type,用于定義網(wǎng)絡(luò)文件的類型和網(wǎng)頁的編碼,決定瀏覽器將以什么形式、什么編碼讀取這個(gè)文件,這就是經(jīng)??吹揭恍?PHP 網(wǎng)頁點(diǎn)擊的結(jié)果卻是下載一個(gè)文件或一張圖片的原因。
Content-Type 標(biāo)頭告訴客戶端實(shí)際返回的內(nèi)容的內(nèi)容類型。
語法格式:
Content-Type: text/html; charset=utf-8 Content-Type: multipart/form-data; boundary=something
實(shí)例:
常見的媒體格式類型如下:
- text/html : HTML格式
- text/plain :純文本格式
- text/xml : XML格式
- image/gif :gif圖片格式
- image/jpeg :jpg圖片格式
- image/png:png圖片格式
以application開頭的媒體格式類型:
- application/xhtml+xml :XHTML格式
- application/xml: XML數(shù)據(jù)格式
- application/atom+xml :Atom XML聚合格式
- application/json: JSON數(shù)據(jù)格式
- application/pdf:pdf格式
- application/msword : Word文檔格式
- application/octet-stream : 二進(jìn)制流數(shù)據(jù)(如常見的文件下載)
- application/x-www-form-urlencoded : <form encType=””>中默認(rèn)的encType,form表單數(shù)據(jù)被編碼為key/value格式發(fā)送到服務(wù)器(表單默認(rèn)的提交數(shù)據(jù)的格式)
另外一種常見的媒體格式是上傳文件之時(shí)使用的:文章來源:http://www.zghlxwxcb.cn/news/detail-569826.html
- multipart/form-data : 需要在表單中進(jìn)行文件上傳時(shí),就需要使用該格式
HTTP content-type 對(duì)照表
文件擴(kuò)展名 | Content-Type(Mime-Type) | 文件擴(kuò)展名 | Content-Type(Mime-Type) |
---|---|---|---|
.*( 二進(jìn)制流,不知道下載文件類型) | application/octet-stream | .tif | image/tiff |
.001 | application/x-001 | .301 | application/x-301 |
.323 | text/h323 | .906 | application/x-906 |
.907 | drawing/907 | .a11 | application/x-a11 |
.acp | audio/x-mei-aac | .ai | application/postscript |
.aif | audio/aiff | .aifc | audio/aiff |
.aiff | audio/aiff | .anv | application/x-anv |
.asa | text/asa | .asf | video/x-ms-asf |
.asp | text/asp | .asx | video/x-ms-asf |
.au | audio/basic | .avi | video/avi |
.awf | application/vnd.adobe.workflow | .biz | text/xml |
.bmp | application/x-bmp | .bot | application/x-bot |
.c4t | application/x-c4t | .c90 | application/x-c90 |
.cal | application/x-cals | .cat | application/vnd.ms-pki.seccat |
.cdf | application/x-netcdf | .cdr | application/x-cdr |
.cel | application/x-cel | .cer | application/x-x509-ca-cert |
.cg4 | application/x-g4 | .cgm | application/x-cgm |
.cit | application/x-cit | .class | java/* |
.cml | text/xml | .cmp | application/x-cmp |
.cmx | application/x-cmx | .cot | application/x-cot |
.crl | application/pkix-crl | .crt | application/x-x509-ca-cert |
.csi | application/x-csi | .css | text/css |
.cut | application/x-cut | .dbf | application/x-dbf |
.dbm | application/x-dbm | .dbx | application/x-dbx |
.dcd | text/xml | .dcx | application/x-dcx |
.der | application/x-x509-ca-cert | .dgn | application/x-dgn |
.dib | application/x-dib | .dll | application/x-msdownload |
.doc | application/msword | .dot | application/msword |
.drw | application/x-drw | .dtd | text/xml |
.dwf | Model/vnd.dwf | .dwf | application/x-dwf |
.dwg | application/x-dwg | .dxb | application/x-dxb |
.dxf | application/x-dxf | .edn | application/vnd.adobe.edn |
.emf | application/x-emf | .eml | message/rfc822 |
.ent | text/xml | .epi | application/x-epi |
.eps | application/x-ps | .eps | application/postscript |
.etd | application/x-ebx | .exe | application/x-msdownload |
.fax | image/fax | .fdf | application/vnd.fdf |
.fif | application/fractals | .fo | text/xml |
.frm | application/x-frm | .g4 | application/x-g4 |
.gbr | application/x-gbr | . | application/x- |
.gif | image/gif | .gl2 | application/x-gl2 |
.gp4 | application/x-gp4 | .hgl | application/x-hgl |
.hmr | application/x-hmr | .hpg | application/x-hpgl |
.hpl | application/x-hpl | .hqx | application/mac-binhex40 |
.hrf | application/x-hrf | .hta | application/hta |
.htc | text/x-component | .htm | text/html |
.html | text/html | .htt | text/webviewhtml |
.htx | text/html | .icb | application/x-icb |
.ico | image/x-icon | .ico | application/x-ico |
.iff | application/x-iff | .ig4 | application/x-g4 |
.igs | application/x-igs | .iii | application/x-iphone |
.img | application/x-img | .ins | application/x-internet-signup |
.isp | application/x-internet-signup | .IVF | video/x-ivf |
.java | java/* | .jfif | image/jpeg |
.jpe | image/jpeg | .jpe | application/x-jpe |
.jpeg | image/jpeg | .jpg | image/jpeg |
.jpg | application/x-jpg | .js | application/x-javascript |
.jsp | text/html | .la1 | audio/x-liquid-file |
.lar | application/x-laplayer-reg | .latex | application/x-latex |
.lavs | audio/x-liquid-secure | .lbm | application/x-lbm |
.lmsff | audio/x-la-lms | .ls | application/x-javascript |
.ltr | application/x-ltr | .m1v | video/x-mpeg |
.m2v | video/x-mpeg | .m3u | audio/mpegurl |
.m4e | video/mpeg4 | .mac | application/x-mac |
.man | application/x-troff-man | .math | text/xml |
.mdb | application/msaccess | .mdb | application/x-mdb |
.mfp | application/x-shockwave-flash | .mht | message/rfc822 |
.mhtml | message/rfc822 | .mi | application/x-mi |
.mid | audio/mid | .midi | audio/mid |
.mil | application/x-mil | .mml | text/xml |
.mnd | audio/x-musicnet-download | .mns | audio/x-musicnet-stream |
.mocha | application/x-javascript | .movie | video/x-sgi-movie |
.mp1 | audio/mp1 | .mp2 | audio/mp2 |
.mp2v | video/mpeg | .mp3 | audio/mp3 |
.mp4 | video/mpeg4 | .mpa | video/x-mpg |
.mpd | application/vnd.ms-project | .mpe | video/x-mpeg |
.mpeg | video/mpg | .mpg | video/mpg |
.mpga | audio/rn-mpeg | .mpp | application/vnd.ms-project |
.mps | video/x-mpeg | .mpt | application/vnd.ms-project |
.mpv | video/mpg | .mpv2 | video/mpeg |
.mpw | application/vnd.ms-project | .mpx | application/vnd.ms-project |
.mtx | text/xml | .mxp | application/x-mmxp |
.net | image/pnetvue | .nrf | application/x-nrf |
.nws | message/rfc822 | .odc | text/x-ms-odc |
.out | application/x-out | .p10 | application/pkcs10 |
.p12 | application/x-pkcs12 | .p7b | application/x-pkcs7-certificates |
.p7c | application/pkcs7-mime | .p7m | application/pkcs7-mime |
.p7r | application/x-pkcs7-certreqresp | .p7s | application/pkcs7-signature |
.pc5 | application/x-pc5 | .pci | application/x-pci |
.pcl | application/x-pcl | .pcx | application/x-pcx |
application/pdf | application/pdf | ||
.pdx | application/vnd.adobe.pdx | .pfx | application/x-pkcs12 |
.pgl | application/x-pgl | .pic | application/x-pic |
.pko | application/vnd.ms-pki.pko | .pl | application/x-perl |
.plg | text/html | .pls | audio/scpls |
.plt | application/x-plt | .png | image/png |
.png | application/x-png | .pot | application/vnd.ms-powerpoint |
.ppa | application/vnd.ms-powerpoint | .ppm | application/x-ppm |
.pps | application/vnd.ms-powerpoint | .ppt | application/vnd.ms-powerpoint |
.ppt | application/x-ppt | .pr | application/x-pr |
.prf | application/pics-rules | .prn | application/x-prn |
.prt | application/x-prt | .ps | application/x-ps |
.ps | application/postscript | .ptn | application/x-ptn |
.pwz | application/vnd.ms-powerpoint | .r3t | text/vnd.rn-realtext3d |
.ra | audio/vnd.rn-realaudio | .ram | audio/x-pn-realaudio |
.ras | application/x-ras | .rat | application/rat-file |
.rdf | text/xml | .rec | application/vnd.rn-recording |
.red | application/x-red | .rgb | application/x-rgb |
.rjs | application/vnd.rn-realsystem-rjs | .rjt | application/vnd.rn-realsystem-rjt |
.rlc | application/x-rlc | .rle | application/x-rle |
.rm | application/vnd.rn-realmedia | .rmf | application/vnd.adobe.rmf |
.rmi | audio/mid | .rmj | application/vnd.rn-realsystem-rmj |
.rmm | audio/x-pn-realaudio | .rmp | application/vnd.rn-rn_music_package |
.rms | application/vnd.rn-realmedia-secure | .rmvb | application/vnd.rn-realmedia-vbr |
.rmx | application/vnd.rn-realsystem-rmx | .rnx | application/vnd.rn-realplayer |
.rp | image/vnd.rn-realpix | .rpm | audio/x-pn-realaudio-plugin |
.rsml | application/vnd.rn-rsml | .rt | text/vnd.rn-realtext |
.rtf | application/msword | .rtf | application/x-rtf |
.rv | video/vnd.rn-realvideo | .sam | application/x-sam |
.sat | application/x-sat | .sdp | application/sdp |
.sdw | application/x-sdw | .sit | application/x-stuffit |
.slb | application/x-slb | .sld | application/x-sld |
.slk | drawing/x-slk | .smi | application/smil |
.smil | application/smil | .smk | application/x-smk |
.snd | audio/basic | .sol | text/plain |
.sor | text/plain | .spc | application/x-pkcs7-certificates |
.spl | application/futuresplash | .spp | text/xml |
.ssm | application/streamingmedia | .sst | application/vnd.ms-pki.certstore |
.stl | application/vnd.ms-pki.stl | .stm | text/html |
.sty | application/x-sty | .svg | text/xml |
.swf | application/x-shockwave-flash | .tdf | application/x-tdf |
.tg4 | application/x-tg4 | .tga | application/x-tga |
.tif | image/tiff | .tif | application/x-tif |
.tiff | image/tiff | .tld | text/xml |
.top | drawing/x-top | .torrent | application/x-bittorrent |
.tsd | text/xml | .txt | text/plain |
.uin | application/x-icq | .uls | text/iuls |
.vcf | text/x-vcard | .vda | application/x-vda |
.vdx | application/vnd.visio | .vml | text/xml |
.vpg | application/x-vpeg005 | .vsd | application/vnd.visio |
.vsd | application/x-vsd | .vss | application/vnd.visio |
.vst | application/vnd.visio | .vst | application/x-vst |
.vsw | application/vnd.visio | .vsx | application/vnd.visio |
.vtx | application/vnd.visio | .vxml | text/xml |
.wav | audio/wav | .wax | audio/x-ms-wax |
.wb1 | application/x-wb1 | .wb2 | application/x-wb2 |
.wb3 | application/x-wb3 | .wbmp | image/vnd.wap.wbmp |
.wiz | application/msword | .wk3 | application/x-wk3 |
.wk4 | application/x-wk4 | .wkq | application/x-wkq |
.wks | application/x-wks | .wm | video/x-ms-wm |
.wma | audio/x-ms-wma | .wmd | application/x-ms-wmd |
.wmf | application/x-wmf | .wml | text/vnd.wap.wml |
.wmv | video/x-ms-wmv | .wmx | video/x-ms-wmx |
.wmz | application/x-ms-wmz | .wp6 | application/x-wp6 |
.wpd | application/x-wpd | .wpg | application/x-wpg |
.wpl | application/vnd.ms-wpl | .wq1 | application/x-wq1 |
.wr1 | application/x-wr1 | .wri | application/x-wri |
.wrk | application/x-wrk | .ws | application/x-ws |
.ws2 | application/x-ws | .wsc | text/scriptlet |
.wsdl | text/xml | .wvx | video/x-ms-wvx |
.xdp | application/vnd.adobe.xdp | .xdr | text/xml |
.xfd | application/vnd.adobe.xfd | .xfdf | application/vnd.adobe.xfdf |
.xhtml | text/html | .xls | application/vnd.ms-excel |
.xls | application/x-xls | .xlw | application/x-xlw |
.xml | text/xml | .xpl | audio/scpls |
.xq | text/xml | .xql | text/xml |
.xquery | text/xml | .xsd | text/xml |
.xsl | text/xml | .xslt | text/xml |
.xwd | application/x-xwd | .x_b | application/x-x_b |
.sis | application/vnd.symbian.install | .sisx | application/vnd.symbian.install |
.x_t | application/x-x_t | .ipa | application/vnd.iphone |
.apk | application/vnd.android.package-archive | .xap | application/x-silverlight-app |
?文章來源地址http://www.zghlxwxcb.cn/news/detail-569826.html
到了這里,關(guān)于HTPP入門教程||HTTP 狀態(tài)碼||HTTP content-type的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!