http學習筆記
一.HTTP請求:HTTP請求分為:
? 1).請求行
? 2).消息頭
? 3).空行
? 4).正文
1.請求行
? [方法 URI HTTP版本信息]
? 如: GET /index.htm HTTP/1.0
2.方法(全部大寫):
? GET????? 請求URI標識的資源
? HEAD???? 請求獲取響應消息頭
? PUT????? 請求存儲資源,并用URI作為其標識
? POST???? 請求服務器接收信息
? CONNECT? ?
? TRACE???
? DELETE
? OPTIONS
二.HTTP響應:
? 1).狀態行
? 2).消息頭
? 3).空行
? 4).正文(資源的內容,比如index.htm文件的文本內容)
1.狀態行
? HTTP版本信息 狀態碼 響應碼描述
? 例: HTTP/1.1 200 OK
2.狀態碼(第一位表示響應的類別)
? 1xx:
? 2xx:
? 3xx:
? 4xx:
? 5xx:
HTTP協議狀態碼具體意義
?? 100? :? Continue
?? 101? :? witchingProtocols
?? 200? :? OK
?? 201? :? Created
?? 202? :? Accepted
?? 203? :? Non-AuthoritativeInformation
?? 204? :? NoContent
?? 205? :? ResetContent
?? 206? :? PartialContent
?? 300? :? MultipleChoices
?? 301? :? MovedPermanently
?? 302? :? Found
?? 303? :? SeeOther
?? 304? :? NotModified
?? 305? :? UseProxy
?? 307? :? TemporaryRedirect
?? 400? :? BadRequest
?? 401? :? Unauthorized
?? 402? :? PaymentRequired
?? 403? :? Forbidden
?? 404? :? NotFound
?? 405? :? MethodNotAllowed
?? 406? :? NotAcceptable
?? 407? :? ProxyAuthenticationRequired
?? 408? :? RequestTime-out
?? 409? :? Conflict
?? 410? :? Gone
?? 411? :? LengthRequired
?? 412? :? PreconditionFailed
?? 413? :? RequestEntityTooLarge
?? 414? :? Request-URITooLarge
?? 415? :? UnsupportedMediaType
?? 416? :? Requestedrangenotsatisfiable
?? 417? :? ExpectationFailed
?? 500? :? InternalServerError
?? 501? :? NotImplemented
?? 502? :? BadGateway
?? 503? :? ServiceUnavailable
?? 504? :? GatewayTime-out
?? 505? :? HTTPVersionnotsupported
三.HTTP消息頭:
1. 普通
2. 請求頭
3. 響應頭
4. 實體頭
格式:(名字大小寫無關)
<名字>:<空格><值>
1.普通頭
? .Cache-Control? (HTTP1.1,? HTTP1.0:Pragma)
????? 緩存指令:
????? 請求時: no-cache,no-store,max-age,max-stale,min-fresh,only-if-cached
????? 響應時: public,private,no-cache,no-store,no-transform,must-revalidate,proxy-revalidate,max-age,s-maxage.
????? 例: Cache-Control: no-cache
? .Date
????? 客戶端:在發送正文時要包含Date,
????? 服務器:在響應時包含Date.
? .Connection
? .Pragma(1.0用)
2. 請求頭
? .Accept
? .Accept-Charset
? .Accept-Encoding
? .Accept-Language
? .Authorization
? .Host(必須的)
? .User-agent
3.響應頭
? .Location
? .Server
? .WWW-Authenticate,要包含在401中.
4.實體頭
? .Content-Encoding
? .Content-Language
? .Content-Length
? .Content-Type
? .Last-Modified
? .Expires
?
posted @ 2006-09-28 15:53 2195113 閱讀(245) | 評論 (0) | 編輯 收藏