HTML -- HTTP服务器状态代码定义(Status Code Definitions)

yanghui0 2011-01-12

引用
1.1 消息1xx(Informational 1xx)

该类状态代码用于表示临时回应。临时回应由状态行(Status-Line)及可选标题组成,由空行终止。HTTP/1.0中没有定义任何1xx的状态代码,所以它们不是对HTTP/1.0请求的  合法回应。实际上,它们主要用于实验用途,这已经超出本文档的范围。

1.2成功2xx(Successful2xx)

表示客户端请求被成功接收、理解、接受。

200OK

请求成功。回应的信息依赖于请求所使用的方法,如下:

GET要请求的资源已经放在回应的实体中了。

HEAD没有实体主体,回应中只包括标题信息。

POST实体(描述或包含操作的结果)。

201Created

请求完成,结果是创建了新资源。新创建资源的URI可在回应的实体中得到。原始服务器应在发出该状态代码前创建该资源。如果该操作不能立即完成,服务器必须在该资源可用时在回应主体中给出提示,否则,服务器端应回应202(可被接受)。

在本文定义的方法,只有POST可以创建资源。

202Accepted

请求被接受,但处理尚未完成。请求可能不一定会最终完成,有可能被处理过程随时中断,在这种情况下,没有办法在异步操作中重新发送状态代码。

202回应是没有义务的,这样做的目的是允许服务器不必等到用户代理和服务器间的连接结束,就可以响应其它过程的请求(象每天运行一次的,基于批处理的过程)。

在某些回应中返回的实体中包括当前请求的状态指示、状态监视器指针或用户对请求能否实现的评估信息。

204NoContent

服务器端已经实现了请求,但是没有返回新的信息。如果客户是用户代理,则勿需为此更新自身的文档视图。该回应主要是为了在不影响用户代理激活文档视图的前提下,进行script语句的输入及其它操作。该回应还可能包括新的、以实体标题形式表示的元信息,它可被当前用户代理激活视图中的文档所使用。

1.3重定向(Redirection3xx)

该类状态码表示用户代理要想完成请求,还需要发出进一步的操作。这些操作只有当后跟的请求是GET或HEAD时,才可由用户代理来实现,而不用与用户进行交互。用户代理永远也不要对请求进行5次以上的重定向操作,这样可能导致无限循环。

300MultipleChoices

该状态码不被HTTP/1.0的应用程序直接使用,只是做为3xx类型回应的缺省解释。存在多个可用的被请求资源。

除非是HEAD请求,否则回应的实体中必须包括这些资源的字符列表及位置信息,由用户或用户代理来决定哪个是最适合的。

如果服务器有首选,它应将对应的URL信息存放在位置域(Locationfield)处,用户代理会根据此域的值来实现自动的重定向。

301MovedPermanently

请求到的资源都会分配一个永久的URL,这样就可以在将来通过该URL来访问此资源。有编辑链接功能的客户端会尽可能地根据服务器端传回的新链接而自动更新请求URI。新的URL必须由回应中的位置域指定。除非是HEAD请求,否则回应的实体主体  (Entity-Body)必须包括对新URL超链接的简要描述。

如果用POST方法发出请求,而接收到301回应状态码。在这种情况下,除非用户确认,否则用户代理不必自动重定向请求,因为这将导致改变已发出请求的环境。

注意:当在接收到301状态码后而自动重定向POST请求时,一些现存的用户代理会错误地将其改为GET请求。

302MovedTemporarily

请求到的资源在一个不同的URL处临时保存。因为重定向有时会被更改,客户端应继续用请求URI来发出以后的请求。新的URL必须由回应中的位置域指定。除非是HEAD请求,否则回应的实体主体(Entity-Body)必须包括对新URL超链接的简要描述。

如果用POST方法发出请求,而接收到302回应状态码。在这种情况下,除非用户确认,否则用户代理不必自动重定向请求,因为这将导致改变已发出请求的环境。

注意:当在接收到302状态码后而自动重定向POST请求时,一些现存的用户代理会错误地将其改为GET请求。

304NotModified

如果客户端成功执行了条件GET请求,而对应文件自If-Modified-Since域所指定的日期以来就没有更新过,服务器应当回应此状态码,而不是将实体主体发送给客户端。回应标题域中只应包括一些相关信息,比如缓存管理器、与实体最近更新(entity'sLast-Modified)日期无关的修改。相关标题域的例子有:日期、服务器、过期时间。每当304回应中给出的域值发生变化,缓存都应当对缓存的实体进行更新。

1.4客户端错误(ClientError)4xx

4xx类的状态码表示客户端发生错误。如果客户端在收到4xx代码时请求还没有完成,它应当立即终止向服务器发送数据。除了回应HEAD请求外,不论错误是临时的还是永久的,服务器端都必须在回应的实体中包含错误状态的解释。这些状态码适用于任何请求方法。

注意:如果客户端正在发送数据,服务器端的TCP实现应当小心,以确保客户端在关闭输入连接之前收到回应包。如果客户端在关闭后仍旧向服务器发送数据,服务器会给客户  端发送一个复位包,清空客户端尚未处理的输入缓冲区,以终止HTTP应用程序的读取、解释活动。

400非法请求(BadRequest)

如果请求的语法不对,服务器将无法理解。客户端在对该请求做出更改之前,不应再次向服务器重复发送该请求。

401未授权(Unauthorized)

请求需要用户授权。回应中的WWW-Authenticate标题域(10.16节)应提示用户以授权方式请求资源。客户端应使用合适的授权标题域(10.2节)来重复该请求。如果请求中已经包括了授权信任信息,那回应的401表示此授权被拒绝。如果用户代理在多次尝试之后,回应一样还是返回401状态代码,用户应当察看一下回应的实体,因为在实体中会包括一些相关的动态信息。HTTP访问授权会在11节中解释。

403禁止(Forbidden)

服务器理解请求,但是拒绝实现该请求。授权对此没有帮助,客户端应当停止重复发送此请求。如果不是用HEAD请求方法,而且服务器端愿意公布请求未被实现原因的前提下,服务器会将拒绝原因写在回应实体中。该状态码一般用于服务器端不想公布请求被拒绝的细节或没有其它的回应可用。

404没有找到(NotFound)

服务器没有找到与请求URI相符的资源。404状态码并不指明状况是临时性的还是永久性的。如果服务器不希望为客户端提供这方面的信息,还回应403(禁止)状态码。

1.5服务器错误(ServerError)5xx

回应代码以‘5’开头的状态码表示服务器端发现自己出现错误,不能继续执行请求。如果客户端在收到5xx状态码时,请求尚未完成,它应当立即停止向服务器发送数据。除了回应HEAD请求外,服务器应当在其回应实体中包括对错误情况的解释、并指明是临时性的还永久性的。

这类回应代码没有标题域,可适用于任何请求方法。

500服务器内部错误(InternalServerError)

服务器碰到了意外情况,使其无法继续回应请求。

501未实现(NotImplemented)

服务器无法提供对请求中所要求功能的支持。如果服务器无法识别请求方法就会回应此状态代码,这意味着不能回应请求所要求的任何资源。

502非法网关(BadGateway)

充当网关或代理的服务器从要发送请求的上游(upstream)服务器收到非法的回应。

503服务不可用(ServiceUnavailable)

服务器当前无法处理请求。这一般是由于服务器临时性超载或维护引起的。该状态码暗示情况是暂时性的,要产生一些延迟。

注意:503状态码并没有暗示服务器在超载时一定要返回此状态码。一些服务器可能希望在超载时采用简单处理,即断掉连接。

----------------------------英文原文-----------------------

EachStatus-Codeisdescribedbelow,includingadescriptionofwhichmethod(s)itcanfollowandanymetainformationrequiredintheresponse.

10.1Informational1xx

Thisclassofstatuscodeindicatesaprovisionalresponse,consistingonlyoftheStatus-Lineandoptionalheaders,andisterminatedbyanemptyline.Therearenorequiredheadersforthisclassofstatuscode.SinceHTTP/1.0didnotdefineany1xxstatuscodes,serversMUSTNOTsenda1xxresponsetoanHTTP/1.0clientexceptunderexperimentalconditions.

AclientMUSTbepreparedtoacceptoneormore1xxstatusresponsespriortoaregularresponse,eveniftheclientdoesnotexpecta100(Continue)statusmessage.Unexpected1xxstatusresponsesMAYbeignoredbyauseragent.

ProxiesMUSTforward1xxresponses,unlesstheconnectionbetweentheproxyanditsclienthasbeenclosed,orunlesstheproxyitselfrequestedthegenerationofthe1xxresponse.(Forexample,ifa

proxyaddsa"Expect:100-continue"fieldwhenitforwardsarequest,thenitneednotforwardthecorresponding100(Continue)response(s).)

10.1.1100Continue

TheclientSHOULDcontinuewithitsrequest.Thisinterimresponseisusedtoinformtheclientthattheinitialpartoftherequesthasbeenreceivedandhasnotyetbeenrejectedbytheserver.TheclientSHOULDcontinuebysendingtheremainderoftherequestor,iftherequesthasalreadybeencompleted,ignorethisresponse.TheserverMUSTsendafinalresponseaftertherequesthasbeencompleted.Seesection8.2.3fordetaileddiscussionoftheuseandhandlingofthisstatuscode.

10.1.2101SwitchingProtocols

Theserverunderstandsandiswillingtocomplywiththeclient'srequest,viatheUpgrademessageheaderfield(section14.42),forachangeintheapplicationprotocolbeingusedonthisconnection.Theserverwillswitchprotocolstothosedefinedbytheresponse'sUpgradeheaderfieldimmediatelyaftertheemptylinewhichterminatesthe101response.

TheprotocolSHOULDbeswitchedonlywhenitisadvantageoustodoso.Forexample,switchingtoanewerversionofHTTPisadvantageousoverolderversions,andswitchingtoareal-time,synchronousprotocolmightbeadvantageouswhendeliveringresourcesthatusesuchfeatures.

10.2Successful2xx

Thisclassofstatuscodeindicatesthattheclient'srequestwassuccessfullyreceived,understood,andaccepted.

10.2.1200OK

Therequesthassucceeded.Theinformationreturnedwiththeresponseisdependentonthemethodusedintherequest,forexample:

GETanentitycorrespondingtotherequestedresourceissentintheresponse;

HEADtheentity-headerfieldscorrespondingtotherequestedresourcearesentintheresponsewithoutanymessage-body;

POSTanentitydescribingorcontainingtheresultoftheaction;

TRACEanentitycontainingtherequestmessageasreceivedbytheendserver.

10.2.2201Created

Therequesthasbeenfulfilledandresultedinanewresourcebeingcreated.ThenewlycreatedresourcecanbereferencedbytheURI(s)returnedintheentityoftheresponse,withthemostspecificURIfortheresourcegivenbyaLocationheaderfield.TheresponseSHOULDincludeanentitycontainingalistofresourcecharacteristicsandlocation(s)fromwhichtheuseroruseragentcanchoosetheonemostappropriate.TheentityformatisspecifiedbythemediatypegivenintheContent-Typeheaderfield.TheoriginserverMUSTcreatetheresourcebeforereturningthe201statuscode.Iftheactioncannotbecarriedoutimmediately,theserverSHOULDrespondwith202(Accepted)responseinstead.

A201responseMAYcontainanETagresponseheaderfieldindicatingthecurrentvalueoftheentitytagfortherequestedvariantjustcreated,seesection14.19.

10.2.3202Accepted

Therequesthasbeenacceptedforprocessing,buttheprocessinghasnotbeencompleted.Therequestmightormightnoteventuallybeactedupon,asitmightbedisallowedwhenprocessingactuallytakesplace.Thereisnofacilityforre-sendingastatuscodefromanasynchronousoperationsuchasthis.

The202responseisintentionallynon-committal.Itspurposeistoallowaservertoacceptarequestforsomeotherprocess(perhapsabatch-orientedprocessthatisonlyrunonceperday)withoutrequiringthattheuseragent'sconnectiontotheserverpersistuntiltheprocessiscompleted.TheentityreturnedwiththisresponseSHOULDincludeanindicationoftherequest'scurrentstatusandeitherapointertoastatusmonitororsomeestimateofwhentheusercanexpecttherequesttobefulfilled.

10.2.4203Non-AuthoritativeInformation

Thereturnedmetainformationintheentity-headerisnotthedefinitivesetasavailablefromtheoriginserver,butisgatheredfromalocalorathird-partycopy.ThesetpresentedMAYbeasubsetorsupersetoftheoriginalversion.Forexample,includinglocalannotationinformationabouttheresourcemightresultinasupersetofthemetainformationknownbytheoriginserver.Useofthisresponsecodeisnotrequiredandisonlyappropriatewhentheresponsewouldotherwisebe200(OK).

10.2.5204NoContent

Theserverhasfulfilledtherequestbutdoesnotneedtoreturnanentity-body,andmightwanttoreturnupdatedmetainformation.TheresponseMAYincludeneworupdatedmetainformationintheformofentity-headers,whichifpresentSHOULDbeassociatedwiththerequestedvariant.

Iftheclientisauseragent,itSHOULDNOTchangeitsdocumentviewfromthatwhichcausedtherequesttobesent.Thisresponseisprimarilyintendedtoallowinputforactionstotakeplacewithoutcausingachangetotheuseragent'sactivedocumentview,althoughanyneworupdatedmetainformationSHOULDbeappliedtothedocumentcurrentlyintheuseragent'sactiveview.

The204responseMUSTNOTincludeamessage-body,andthusisalwaysterminatedbythefirstemptylineaftertheheaderfields.

10.2.6205ResetContent

TheserverhasfulfilledtherequestandtheuseragentSHOULDresetthedocumentviewwhichcausedtherequesttobesent.Thisresponseisprimarilyintendedtoallowinputforactionstotakeplaceviauserinput,followedbyaclearingoftheforminwhichtheinputisgivensothattheusercaneasilyinitiateanotherinputaction.TheresponseMUSTNOTincludeanentity.

10.2.7206PartialContent

TheserverhasfulfilledthepartialGETrequestfortheresource.TherequestMUSThaveincludedaRangeheaderfield(section14.35)indicatingthedesiredrange,andMAYhaveincludedanIf-Rangeheaderfield(section14.27)tomaketherequestconditional.

TheresponseMUSTincludethefollowingheaderfields:

-EitheraContent-Rangeheaderfield(section14.16)indicating

therangeincludedwiththisresponse,oramultipart/byteranges

Content-TypeincludingContent-Rangefieldsforeachpart.Ifa

Content-Lengthheaderfieldispresentintheresponse,its

valueMUSTmatchtheactualnumberofOCTETstransmittedinthe

message-body.

-Date

-ETagand/orContent-Location,iftheheaderwouldhavebeensent

ina200responsetothesamerequest

-Expires,Cache-Control,and/orVary,ifthefield-valuemight

differfromthatsentinanypreviousresponseforthesame

variant

Ifthe206responseistheresultofanIf-Rangerequestthatusedastrongcachevalidator(seesection13.3.3),theresponseSHOULDNOTincludeotherentity-headers.IftheresponseistheresultofanIf-Rangerequestthatusedaweakvalidator,theresponseMUSTNOTincludeotherentity-headers;thispreventsinconsistenciesbetweencachedentity-bodiesandupdatedheaders.Otherwise,theresponseMUSTincludealloftheentity-headersthatwouldhavebeenreturnedwitha200(OK)responsetothesamerequest.

AcacheMUSTNOTcombinea206responsewithotherpreviouslycachedcontentiftheETagorLast-Modifiedheadersdonotmatchexactly,see13.5.4.

AcachethatdoesnotsupporttheRangeandContent-RangeheadersMUSTNOTcache206(Partial)responses.

10.3Redirection3xx

Thisclassofstatuscodeindicatesthatfurtheractionneedstobetakenbytheuseragentinordertofulfilltherequest.TheactionrequiredMAYbecarriedoutbytheuseragentwithoutinteractionwiththeuserifandonlyifthemethodusedinthesecondrequestisGETorHEAD.AclientSHOULDdetectinfiniteredirectionloops,sincesuchloopsgeneratenetworktrafficforeachredirection.

Note:previousversionsofthisspecificationrecommendeda

maximumoffiveredirections.Contentdevelopersshouldbeaware

thattheremightbeclientsthatimplementsuchafixed

limitation.

10.3.1300MultipleChoices

Therequestedresourcecorrespondstoanyoneofasetofrepresentations,eachwithitsownspecificlocation,andagent-drivennegotiationinformation(section12)isbeingprovidedsothattheuser(oruseragent)canselectapreferredrepresentationandredirectitsrequesttothatlocation.

UnlessitwasaHEADrequest,theresponseSHOULDincludeanentitycontainingalistofresourcecharacteristicsandlocation(s)fromwhichtheuseroruseragentcanchoosetheonemostappropriate.TheentityformatisspecifiedbythemediatypegivenintheContent-Typeheaderfield.Dependingupontheformatandthecapabilitiesof

theuseragent,selectionofthemostappropriatechoiceMAYbeperformedautomatically.However,thisspecificationdoesnotdefineanystandardforsuchautomaticselection.

Iftheserverhasapreferredchoiceofrepresentation,itSHOULDincludethespecificURIforthatrepresentationintheLocationfield;useragentsMAYusetheLocationfieldvalueforautomaticredirection.Thisresponseiscacheableunlessindicatedotherwise.

10.3.2301MovedPermanently

TherequestedresourcehasbeenassignedanewpermanentURIandanyfuturereferencestothisresourceSHOULDuseoneofthereturnedURIs.Clientswithlinkeditingcapabilitiesoughttoautomaticallyre-linkreferencestotheRequest-URItooneormoreofthenewreferencesreturnedbytheserver,wherepossible.Thisresponseiscacheableunlessindicatedotherwise.

ThenewpermanentURISHOULDbegivenbytheLocationfieldintheresponse.UnlesstherequestmethodwasHEAD,theentityoftheresponseSHOULDcontainashorthypertextnotewithahyperlinktothenewURI(s).

Ifthe301statuscodeisreceivedinresponsetoarequestotherthanGETorHEAD,theuseragentMUSTNOTautomaticallyredirecttherequestunlessitcanbeconfirmedbytheuser,sincethismightchangetheconditionsunderwhichtherequestwasissued.

Note:WhenautomaticallyredirectingaPOSTrequestafter

receivinga301statuscode,someexistingHTTP/1.0useragents

willerroneouslychangeitintoaGETrequest.

10.3.3302Found

TherequestedresourceresidestemporarilyunderadifferentURI.Sincetheredirectionmightbealteredonoccasion,theclientSHOULDcontinuetousetheRequest-URIforfuturerequests.ThisresponseisonlycacheableifindicatedbyaCache-ControlorExpiresheaderfield.

ThetemporaryURISHOULDbegivenbytheLocationfieldintheresponse.UnlesstherequestmethodwasHEAD,theentityoftheresponseSHOULDcontainashorthypertextnotewithahyperlinktothenewURI(s).

Ifthe302statuscodeisreceivedinresponsetoarequestotherthanGETorHEAD,theuseragentMUSTNOTautomaticallyredirecttherequestunlessitcanbeconfirmedbytheuser,sincethismightchangetheconditionsunderwhichtherequestwasissued.

Note:RFC1945andRFC2068specifythattheclientisnotallowed

tochangethemethodontheredirectedrequest.However,most

existinguseragentimplementationstreat302asifitwerea303

response,performingaGETontheLocationfield-valueregardless

oftheoriginalrequestmethod.Thestatuscodes303and307have

beenaddedforserversthatwishtomakeunambiguouslyclearwhich

kindofreactionisexpectedoftheclient.

10.3.4303SeeOther

TheresponsetotherequestcanbefoundunderadifferentURIandSHOULDberetrievedusingaGETmethodonthatresource.ThismethodexistsprimarilytoallowtheoutputofaPOST-activatedscripttoredirecttheuseragenttoaselectedresource.ThenewURIisnotasubstitutereferencefortheoriginallyrequestedresource.The303responseMUSTNOTbecached,buttheresponsetothesecond(redirected)requestmightbecacheable.

ThedifferentURISHOULDbegivenbytheLocationfieldintheresponse.UnlesstherequestmethodwasHEAD,theentityoftheresponseSHOULDcontainashorthypertextnotewithahyperlinktothenewURI(s).

Note:Manypre-HTTP/1.1useragentsdonotunderstandthe303

status.Wheninteroperabilitywithsuchclientsisaconcern,the

302statuscodemaybeusedinstead,sincemostuseragentsreact

toa302responseasdescribedherefor303.

10.3.5304NotModified

IftheclienthasperformedaconditionalGETrequestandaccessisallowed,butthedocumenthasnotbeenmodified,theserverSHOULDrespondwiththisstatuscode.The304responseMUSTNOTcontainamessage-body,andthusisalwaysterminatedbythefirstemptylineaftertheheaderfields.

TheresponseMUSTincludethefollowingheaderfields:

-Date,unlessitsomissionisrequiredbysection14.18.1

Ifaclocklessoriginserverobeystheserules,andproxiesandclientsaddtheirownDatetoanyresponsereceivedwithoutone(asalreadyspecifiedby[RFC2068],section14.19),cacheswilloperatecorrectly.

-ETagand/orContent-Location,iftheheaderwouldhavebeensent

ina200responsetothesamerequest

-Expires,Cache-Control,and/orVary,ifthefield-valuemight

differfromthatsentinanypreviousresponseforthesame

variant

IftheconditionalGETusedastrongcachevalidator(seesection13.3.3),theresponseSHOULDNOTincludeotherentity-headers.Otherwise(i.e.,theconditionalGETusedaweakvalidator),theresponseMUSTNOTincludeotherentity-headers;thispreventsinconsistenciesbetweencachedentity-bodiesandupdatedheaders.

Ifa304responseindicatesanentitynotcurrentlycached,thenthecacheMUSTdisregardtheresponseandrepeattherequestwithouttheconditional.

Ifacacheusesareceived304responsetoupdateacacheentry,thecacheMUSTupdatetheentrytoreflectanynewfieldvaluesgivenintheresponse.

10.3.6305UseProxy

TherequestedresourceMUSTbeaccessedthroughtheproxygivenbytheLocationfield.TheLocationfieldgivestheURIoftheproxy.Therecipientisexpectedtorepeatthissinglerequestviatheproxy.305responsesMUSTonlybegeneratedbyoriginservers.

Note:RFC2068wasnotclearthat305wasintendedtoredirecta

singlerequest,andtobegeneratedbyoriginserversonly.Not

observingtheselimitationshassignificantsecurityconsequences.

10.3.7306(Unused)

The306statuscodewasusedinapreviousversionofthespecification,isnolongerused,andthecodeisreserved.

10.3.8307TemporaryRedirect

TherequestedresourceresidestemporarilyunderadifferentURI.SincetheredirectionMAYbealteredonoccasion,theclientSHOULDcontinuetousetheRequest-URIforfuturerequests.ThisresponseisonlycacheableifindicatedbyaCache-ControlorExpiresheaderfield.

ThetemporaryURISHOULDbegivenbytheLocationfieldintheresponse.UnlesstherequestmethodwasHEAD,theentityoftheresponseSHOULDcontainashorthypertextnotewithahyperlinktothenewURI(s),sincemanypre-HTTP/1.1useragentsdonotunderstandthe307status.Therefore,thenoteSHOULDcontaintheinformationnecessaryforausertorepeattheoriginalrequestonthenewURI.

Ifthe307statuscodeisreceivedinresponsetoarequestotherthanGETorHEAD,theuseragentMUSTNOTautomaticallyredirecttherequestunlessitcanbeconfirmedbytheuser,sincethismightchangetheconditionsunderwhichtherequestwasissued.

10.4ClientError4xx

The4xxclassofstatuscodeisintendedforcasesinwhichtheclientseemstohaveerred.ExceptwhenrespondingtoaHEADrequest,theserverSHOULDincludeanentitycontaininganexplanationoftheerrorsituation,andwhetheritisatemporaryorpermanentcondition.Thesestatuscodesareapplicabletoanyrequestmethod.UseragentsSHOULDdisplayanyincludedentitytotheuser.

Iftheclientissendingdata,aserverimplementationusingTCPSHOULDbecarefultoensurethattheclientacknowledgesreceiptofthepacket(s)containingtheresponse,beforetheserverclosestheinputconnection.Iftheclientcontinuessendingdatatotheserveraftertheclose,theserver'sTCPstackwillsendaresetpackettotheclient,whichmayerasetheclient'sunacknowledgedinputbuffersbeforetheycanbereadandinterpretedbytheHTTPapplication.

10.4.1400BadRequest

Therequestcouldnotbeunderstoodbytheserverduetomalformedsyntax.TheclientSHOULDNOTrepeattherequestwithoutmodifications.

10.4.2401Unauthorized

Therequestrequiresuserauthentication.TheresponseMUSTincludeaWWW-Authenticateheaderfield(section14.47)containingachallengeapplicabletotherequestedresource.TheclientMAYrepeattherequestwithasuitableAuthorizationheaderfield(section14.8).IftherequestalreadyincludedAuthorizationcredentials,thenthe401responseindicatesthatauthorizationhasbeenrefusedforthosecredentials.Ifthe401responsecontainsthesamechallengeasthepriorresponse,andtheuseragenthasalreadyattemptedauthenticationatleastonce,thentheuserSHOULDbepresentedtheentitythatwasgivenintheresponse,sincethatentitymightincluderelevantdiagnosticinformation.HTTPaccessauthenticationisexplainedin"HTTPAuthentication:BasicandDigestAccessAuthentication"[43].

10.4.3402PaymentRequired

Thiscodeisreservedforfutureuse.

10.4.4403Forbidden

Theserverunderstoodtherequest,butisrefusingtofulfillit.AuthorizationwillnothelpandtherequestSHOULDNOTberepeated.IftherequestmethodwasnotHEADandtheserverwishestomakepublicwhytherequesthasnotbeenfulfilled,itSHOULDdescribethereasonfortherefusalintheentity.Iftheserverdoesnotwishtomakethisinformationavailabletotheclient,thestatuscode404(NotFound)canbeusedinstead.

10.4.5404NotFound

TheserverhasnotfoundanythingmatchingtheRequest-URI.Noindicationisgivenofwhethertheconditionistemporaryorpermanent.The410(Gone)statuscodeSHOULDbeusediftheserverknows,throughsomeinternallyconfigurablemechanism,thatanoldresourceispermanentlyunavailableandhasnoforwardingaddress.Thisstatuscodeiscommonlyusedwhentheserverdoesnotwishtorevealexactlywhytherequesthasbeenrefused,orwhennootherresponseisapplicable.

10.4.6405MethodNotAllowed

ThemethodspecifiedintheRequest-LineisnotallowedfortheresourceidentifiedbytheRequest-URI.TheresponseMUSTincludeanAllowheadercontainingalistofvalidmethodsfortherequestedresource.

10.4.7406NotAcceptable

Theresourceidentifiedbytherequestisonlycapableofgeneratingresponseentitieswhichhavecontentcharacteristicsnotacceptableaccordingtotheacceptheaderssentintherequest.

UnlessitwasaHEADrequest,theresponseSHOULDincludeanentitycontainingalistofavailableentitycharacteristicsandlocation(s)fromwhichtheuseroruseragentcanchoosetheonemostappropriate.TheentityformatisspecifiedbythemediatypegivenintheContent-Typeheaderfield.Dependingupontheformatandthecapabilitiesoftheuseragent,selectionofthemostappropriatechoiceMAYbeperformedautomatically.However,thisspecificationdoesnotdefineanystandardforsuchautomaticselection.

Note:HTTP/1.1serversareallowedtoreturnresponseswhichare

notacceptableaccordingtotheacceptheaderssentinthe

request.Insomecases,thismayevenbepreferabletosendinga

406response.Useragentsareencouragedtoinspecttheheadersof

anincomingresponsetodetermineifitisacceptable.

Iftheresponsecouldbeunacceptable,auseragentSHOULDtemporarilystopreceiptofmoredataandquerytheuserforadecisiononfurtheractions.

10.4.8407ProxyAuthenticationRequired

Thiscodeissimilarto401(Unauthorized),butindicatesthattheclientmustfirstauthenticateitselfwiththeproxy.TheproxyMUSTreturnaProxy-Authenticateheaderfield(section14.33)containingachallengeapplicabletotheproxyfortherequestedresource.TheclientMAYrepeattherequestwithasuitableProxy-Authorizationheaderfield(section14.34).HTTPaccessauthenticationisexplainedin"HTTPAuthentication:BasicandDigestAccessAuthentication"[43].

10.4.9408RequestTimeout

Theclientdidnotproducearequestwithinthetimethattheserverwaspreparedtowait.TheclientMAYrepeattherequestwithoutmodificationsatanylatertime.

10.4.10409Conflict

Therequestcouldnotbecompletedduetoaconflictwiththecurrentstateoftheresource.Thiscodeisonlyallowedinsituationswhereitisexpectedthattheusermightbeabletoresolvetheconflictandresubmittherequest.TheresponsebodySHOULDincludeenough

informationfortheusertorecognizethesourceoftheconflict.Ideally,theresponseentitywouldincludeenoughinformationfortheuseroruseragenttofixtheproblem;however,thatmightnotbepossibleandisnotrequired.

ConflictsaremostlikelytooccurinresponsetoaPUTrequest.Forexample,ifversioningwerebeingusedandtheentitybeingPUTincludedchangestoaresourcewhichconflictwiththosemadebyanearlier(third-party)request,theservermightusethe409responsetoindicatethatitcan'tcompletetherequest.Inthiscase,theresponseentitywouldlikelycontainalistofthedifferencesbetweenthetwoversionsinaformatdefinedbytheresponseContent-Type.

10.4.11410Gone

Therequestedresourceisnolongeravailableattheserverandnoforwardingaddressisknown.Thisconditionisexpectedtobeconsideredpermanent.ClientswithlinkeditingcapabilitiesSHOULDdeletereferencestotheRequest-URIafteruserapproval.Iftheserverdoesnotknow,orhasnofacilitytodetermine,whetherornottheconditionispermanent,thestatuscode404(NotFound)SHOULDbeusedinstead.Thisresponseiscacheableunlessindicatedotherwise.

The410responseisprimarilyintendedtoassistthetaskofwebmaintenancebynotifyingtherecipientthattheresourceisintentionallyunavailableandthattheserverownersdesirethatremotelinkstothatresourceberemoved.Suchaneventiscommonforlimited-time,promotionalservicesandforresourcesbelongingtoindividualsnolongerworkingattheserver'ssite.Itisnotnecessarytomarkallpermanentlyunavailableresourcesas"gone"ortokeepthemarkforanylengthoftime--thatislefttothediscretionoftheserverowner.

10.4.12411LengthRequired

TheserverrefusestoaccepttherequestwithoutadefinedContent-Length.TheclientMAYrepeattherequestifitaddsavalidContent-Lengthheaderfieldcontainingthelengthofthemessage-bodyintherequestmessage.

10.4.13412PreconditionFailed

Thepreconditiongiveninoneormoreoftherequest-headerfieldsevaluatedtofalsewhenitwastestedontheserver.Thisresponsecodeallowstheclienttoplacepreconditionsonthecurrentresourcemetainformation(headerfielddata)andthuspreventtherequestedmethodfrombeingappliedtoaresourceotherthantheoneintended.

10.4.14413RequestEntityTooLarge

Theserverisrefusingtoprocessarequestbecausetherequestentityislargerthantheserveriswillingorabletoprocess.TheserverMAYclosetheconnectiontopreventtheclientfromcontinuingtherequest.

Iftheconditionistemporary,theserverSHOULDincludeaRetry-AfterheaderfieldtoindicatethatitistemporaryandafterwhattimetheclientMAYtryagain.

10.4.15414Request-URITooLong

TheserverisrefusingtoservicetherequestbecausetheRequest-URIislongerthantheserveriswillingtointerpret.ThisrareconditionisonlylikelytooccurwhenaclienthasimproperlyconvertedaPOSTrequesttoaGETrequestwithlongqueryinformation,whentheclienthasdescendedintoaURI"blackhole"ofredirection(e.g.,aredirectedURIprefixthatpointstoasuffixofitself),orwhentheserverisunderattackbyaclientattemptingtoexploitsecurityholespresentinsomeserversusingfixed-lengthbuffersforreadingormanipulatingtheRequest-URI.

10.4.16415UnsupportedMediaType

Theserverisrefusingtoservicetherequestbecausetheentityoftherequestisinaformatnotsupportedbytherequestedresourcefortherequestedmethod.

10.4.17416RequestedRangeNotSatisfiable

AserverSHOULDreturnaresponsewiththisstatuscodeifarequestincludedaRangerequest-headerfield(section14.35),andnoneoftherange-specifiervaluesinthisfieldoverlapthecurrentextentoftheselectedresource,andtherequestdidnotincludeanIf-Rangerequest-headerfield.(Forbyte-ranges,thismeansthatthefirst-byte-posofallofthebyte-range-specvaluesweregreaterthanthecurrentlengthoftheselectedresource.)

Whenthisstatuscodeisreturnedforabyte-rangerequest,theresponseSHOULDincludeaContent-Rangeentity-headerfieldspecifyingthecurrentlengthoftheselectedresource(seesection14.16).ThisresponseMUSTNOTusethemultipart/byterangescontent-type.

10.4.18417ExpectationFailed

TheexpectationgiveninanExpectrequest-headerfield(seesection14.20)couldnotbemetbythisserver,or,iftheserverisaproxy,theserverhasunambiguousevidencethattherequestcouldnotbemetbythenext-hopserver.

10.5ServerError5xx

Responsestatuscodesbeginningwiththedigit"5"indicatecasesinwhichtheserverisawarethatithaserredorisincapableofperformingtherequest.ExceptwhenrespondingtoaHEADrequest,theserverSHOULDincludeanentitycontaininganexplanationoftheerrorsituation,andwhetheritisatemporaryorpermanentcondition.UseragentsSHOULDdisplayanyincludedentitytotheuser.Theseresponsecodesareapplicabletoanyrequestmethod.

10.5.1500InternalServerError

Theserverencounteredanunexpectedconditionwhichpreventeditfromfulfillingtherequest.

10.5.2501NotImplemented

Theserverdoesnotsupportthefunctionalityrequiredtofulfilltherequest.Thisistheappropriateresponsewhentheserverdoesnotrecognizetherequestmethodandisnotcapableofsupportingitforanyresource.

10.5.3502BadGateway

Theserver,whileactingasagatewayorproxy,receivedaninvalidresponsefromtheupstreamserveritaccessedinattemptingtofulfilltherequest.

10.5.4503ServiceUnavailable

Theserveriscurrentlyunabletohandletherequestduetoatemporaryoverloadingormaintenanceoftheserver.Theimplicationisthatthisisatemporaryconditionwhichwillbealleviatedaftersomedelay.Ifknown,thelengthofthedelayMAYbeindicatedinaRetry-Afterheader.IfnoRetry-Afterisgiven,theclientSHOULDhandletheresponseasitwouldfora500response.

Note:Theexistenceofthe503statuscodedoesnotimplythata

servermustuseitwhenbecomingoverloaded.Someserversmaywish

tosimplyrefusetheconnection.

10.5.5504GatewayTimeout

Theserver,whileactingasagatewayorproxy,didnotreceiveatimelyresponsefromtheupstreamserverspecifiedbytheURI(e.g.HTTP,FTP,LDAP)orsomeotherauxiliaryserver(e.g.DNS)itneededtoaccessinattemptingtocompletetherequest.

Note:Notetoimplementors:somedeployedproxiesareknownto

return400or500whenDNSlookupstimeout.

10.5.6505HTTPVersionNotSupported

Theserverdoesnotsupport,orrefusestosupport,theHTTPprotocolversionthatwasusedintherequestmessage.Theserverisindicatingthatitisunableorunwillingtocompletetherequestusingthesamemajorversionastheclient,asdescribedinsection3.1,otherthanwiththiserrormessage.TheresponseSHOULDcontainanentitydescribingwhythatversionisnotsupportedandwhatotherprotocolsaresupportedbythatserver.

==========================================================

400Invalidsyntax.语法问题

401Accessdenied.访问拒绝

402Paymentrequired.必须完整

403Requestforbidden.请求被禁止

404Objectnotfound.对象没有找到

405Methodisnotallowed.方法不允许

406Noresponseacceptabletoclientfound.客户端没有响应

407Proxyauthenticationrequired.代理需要验证

408Servertimedoutwaitingforrequest.等等请求时服务器断开连接

409Usershouldresubmitwithmoreinfo.有冲突用户应该进行检查

410Resourceisnolongeravailable.资源不可用

411Serverrefusedtoacceptrequestwithoutalength.服务器拒绝接受没有长度的请求

412Preconditiongiveninrequestfailed.放弃请求失败的条件

413Requestentitywastoolarge.请求太大

414RequestUniformResourceIdentifier(URI)toolong.请求的URI太长

415Unsupportedmediatype.不支持MEDIA类型

449Retryafterdoingtheappropriateaction.在作了适当动作后重试

500Internalservererror.服务器内部错误

501Serverdoesnotsupportthefunctionalityrequiredtofulfilltherequest.服务器不支持请求的功能

502Errorresponsereceivedfromgateway.从网关收到错误应答

503Temporarilyoverloaded.过载

504Timedoutwaitingforgateway.等待网关时请求断开

505HTTPversionnotsupported.不支持HTTP的版本

HTTPstatuscodesreturnedbyserversontheInternet.

从Internet返回的HTTPstatus代码(HTTP状态字)

HTTP_STATUS_CONTINUE(100)

Therequestcanbecontinued.

请求不能被继续

HTTP_STATUS_SWITCH_PROTOCOLS(101)

Theserverhasswitchedprotocolsinanupgradeheader.

通过新的header服务器的协议被转换了

HTTP_STATUS_OK(200)

Therequestcompletedsuccessfully.

请求成功的完成

HTTP_STATUS_CREATED(201)

Therequesthasbeenfulfilledandresultedinthecreationofanewresource.

通过新的资源请求已经被完成

HTTP_STATUS_ACCEPTED(202)

Therequesthasbeenacceptedforprocessing,buttheprocessinghasnotbeencompleted.

请求已经被接受处理,但是处理还没有完成

HTTP_STATUS_PARTIAL(203)

Thereturnedmetainformationintheentity-headerisnotthedefinitivesetavailablefromtheoriginserver.

从服务器返回的在entity-header中的meta信息是无效的

HTTP_STATUS_NO_CONTENT(204)

Theserverhasfulfilledtherequest,butthereisnonewinformationtosendback.

服务器实现了请求,但是没有返回信息

HTTP_STATUS_RESET_CONTENT(205)

Therequesthasbeencompleted,andtheclientprogramshouldresetthedocumentviewthatcausedtherequesttobesenttoallowtheusertoeasilyinitiateanotherinputaction.

请求已经被完成,并且web程序(客户端程序浏览器程序)已经重置了文档视图目录(content),这个目录很容易允许使用者用另一个动作发送请求

HTTP_STATUS_PARTIAL_CONTENT(206)

TheserverhasfulfilledthepartialGETrequestfortheresource.

服务器已经为资源完成了部分GET请求

HTTP_STATUS_AMBIGUOUS(300)

Theservercouldn'tdecidewhattoreturn.

服务器不能判定返回什么

HTTP_STATUS_MOVED(301)

TherequestedresourcehasbeenassignedtoanewpermanentURI(UniformResourceIdentifier),andanyfuturereferencestothisresourceshouldbedoneusingoneofthereturnedURIs.

被请求的资源已经被分配给新的URI,并且以后引用时都使用这个URIs资源。

HTTP_STATUS_REDIRECT(302)

TherequestedresourceresidestemporarilyunderadifferentURI(UniformResourceIdentifier).

请求的资源临时在不同的uri下

HTTP_STATUS_REDIRECT_METHOD(303)

TheresponsetotherequestcanbefoundunderadifferentURI(UniformResourceIdentifier)andshouldberetrievedusingaGETHTTPverbonthatresource.

请求的资源不能在不同的uri下找到,并且从新使用GETHTTP在服务器上从新检索

HTTP_STATUS_NOT_MODIFIED(304)

Therequestedresourcehasnotbeenmodified.

请求的资源没有被改变

HTTP_STATUS_USE_PROXY(305)

Therequestedresourcemustbeaccessedthroughtheproxygivenbythelocationfield.

请求的资源必须通过特定的代理获得

HTTP_STATUS_REDIRECT_KEEP_VERB(307)

TheredirectedrequestkeepsthesameHTTPverb.HTTP/1.1behavior.

从定位请求,

HTTP_STATUS_BAD_REQUEST(400)

Therequestcouldnotbeprocessedbytheserverduetoinvalidsyntax.

因为语法不能被服务器处理

HTTP_STATUS_DENIED(401)

Therequestedresourcerequiresuserauthentication.

请求资源命令必须被验证(拒绝访问)

HTTP_STATUS_PAYMENT_REQ(402)

NotcurrentlyimplementedintheHTTPprotocol.

没有完全实现HTTP协议

HTTP_STATUS_FORBIDDEN(403)

Theserverunderstoodtherequest,butisrefusingtofulfillit.

服务器理解了请求,但是拒绝完成他

HTTP_STATUS_NOT_FOUND(404)

TheserverhasnotfoundanythingmatchingtherequestedURI(UniformResourceIdentifier).

没有找到任何被指定的URI

HTTP_STATUS_BAD_METHOD(405)

TheHTTPverbusedisnotallowed.

Http动作不被允许

HTTP_STATUS_NONE_ACCEPTABLE(406)

Noresponsesacceptabletotheclientwerefound.

应答没有被客户接受

HTTP_STATUS_PROXY_AUTH_REQ(407)

Proxyauthenticationrequired.

代理必须被验证

HTTP_STATUS_REQUEST_TIMEOUT(408)

Theservertimedoutwaitingfortherequest.

服务器在等待请求时中止了

HTTP_STATUS_CONFLICT(409)

Therequestcouldnotbecompletedduetoaconflictwiththecurrentstateoftheresource.Theusershouldresubmitwithmoreinformation.

请求不能被完成,问题是资源冲突。用户应该进行调整

HTTP_STATUS_GONE(410)

Therequestedresourceisnolongeravailableattheserver,andnoforwardingaddressisknown.

请求的资源在服务器上不再可用,而且没有转发地址

HTTP_STATUS_LENGTH_REQUIRED(411)

Theserverrefusestoaccepttherequestwithoutadefinedcontentlength.

服务器拒绝接受没有定义目录大小的请求

HTTP_STATUS_PRECOND_FAILED(412)

Thepreconditiongiveninoneormoreoftherequestheaderfieldsevaluatedtofalsewhenitwastestedontheserver.

当在服务器上测试请求头文件放弃一个或者多个请求的条件

HTTP_STATUS_REQUEST_TOO_LARGE(413)

Theserverisrefusingtoprocessarequestbecausetherequestentityislargerthantheserveriswillingorabletoprocess.

服务器拒绝处理请求,原因是请求的大小超过服务器能够处理的大小

HTTP_STATUS_URI_TOO_LONG(414)

TheserverisrefusingtoservicetherequestbecausetherequestURI(UniformResourceIdentifier)islongerthantheserveriswillingtointerpret.

服务器拒绝服务,原因是请求的URI超过了服务器能够揭示的长度

HTTP_STATUS_UNSUPPORTED_MEDIA(415)

Theserverisrefusingtoservicetherequestbecausetheentityoftherequestisinaformatnotsupportedbytherequestedresourcefortherequestedmethod.

服务器拒绝服务,原因是请求格式不被支持

HTTP_STATUS_RETRY_WITH(449)

Therequestshouldberetriedafterdoingtheappropriateaction.

在作了适当的动作后请求被重试

HTTP_STATUS_SERVER_ERROR(500)

Theserverencounteredanunexpectedconditionthatpreventeditfromfulfillingtherequest.

服务器遇到请求失败意外

HTTP_STATUS_NOT_SUPPORTED(501)

Theserverdoesnotsupportthefunctionalityrequiredtofulfilltherequest.

服务器不支持必须完成请求的功能

HTTP_STATUS_BAD_GATEWAY(502)

Theserver,whileactingasagatewayorproxy,receivedaninvalidresponsefromtheupstreamserveritaccessedinattemptingtofulfilltherequest.

服务器当作为网关或代理时,从上行服务器接受的响应请求失败

HTTP_STATUS_SERVICE_UNAVAIL(503)

Theserviceistemporarilyoverloaded.

【服务器暂时被block】

服务器负载

HTTP_STATUS_GATEWAY_TIMEOUT(504)

Therequestwastimedoutwaitingforagateway.

等待网关时请求断开,没有响应

HTTP_STATUS_VERSION_NOT_SUP(505)

Theserverdoesnotsupport,orrefusestosupport,theHTTPprotocolversionthatwasusedintherequestmessage.

服务器不支持或者拒绝支持正在使用请求的HTTP协议的版本

相关推荐

guoscy / 0评论 2011-03-09

fengziboy / 0评论 2012-02-11