`
zhang_xzhi_xjtu
  • 浏览: 536372 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

RFC2616 HTTP/1.1

 
阅读更多
*************************************************************************************************
目录
1 Introduction
2 Notational Conventions and Generic Grammar
3 Protocol Parameters
4 HTTP Message
5 Request
6 Response
7 Entity
8 Connections
9 Method Definitions
10 Status Code Definitions
*************************************************************************************************
1 Introduction


1.4 Overall Operation

There are three common forms of intermediary: proxy, gateway, and tunnel.

A proxy is a forwarding agent, receiving requests for a URI in its absolute form, rewriting all or part of the message, and forwarding the reformatted request toward the server identified by the URI.

A gateway is a receiving agent, acting as a layer above some other server(s) and, if necessary, translating the requests to the underlying server’s protocol.

A tunnel acts as a relay point between two connections without changing the messages; tunnels are used when the communication needs to pass through an
intermediary (such as a firewall) even when the intermediary cannot understand the contents of the messages.

This distinction is important because some HTTP communication options may apply only to the connection with the nearest, nontunnel
neighbor, only to the end-points of the chain, or to all connections along the chain.


In HTTP/1.0, most implementations used a new connection for each request/response exchange.
In HTTP/1.1, a connection may be used for one or more request/response exchanges, although connections may be closed for a variety of reasons (see section 8.1).

*************************************************************************************************
2 Notational Conventions and Generic Grammar


2.1 Augmented BNF


name = definition
"literal"
rule1 | rule2
(rule1 rule2)
*rule
[rule]   =   *1(foo bar) 可选项
N rule   =   <n>*<n>(element)
#rule  逗号分隔的列表
; comment
implied *LWS  linear white space



2.2 Basic Rules

OCTET = <any 8-bit sequence of data>
CHAR = <any US-ASCII character (octets 0 - 127)>
UPALPHA = <any US-ASCII uppercase letter "A".."Z">
LOALPHA = <any US-ASCII lowercase letter "a".."z">
ALPHA = UPALPHA | LOALPHA
DIGIT = <any US-ASCII digit "0".."9">
CTL = <any US-ASCII control character
(octets 0 - 31) and DEL (127)>
CR = <US-ASCII CR, carriage return (13)>
LF = <US-ASCII LF, linefeed (10)>
SP = <US-ASCII SP, space (32)>
HT = <US-ASCII HT, horizontal-tab (9)>
<"> = <US-ASCII double-quote mark (34)>

CRLF = CR LF
LWS = [CRLF] 1*( SP | HT )
TEXT = <any OCTET except CTLs,but including LWS>
HEX = "A" | "B" | "C" | "D" | "E" | "F" | "a" | "b" | "c" | "d" | "e" | "f" | DIGIT
token = 1*<any CHAR except CTLs or separators>

separators = "(" | ")" | "<" | ">" | "@" | "," | ";" | ":" | "\" | <"> | "/" | "[" | "]" | "?" | "=" | "{" | "}" | SP | HT

comment = "(" *( ctext | quoted-pair | comment ) ")"
ctext = <any TEXT excluding "(" and ")">

quoted-string = ( <"> *(qdtext | quoted-pair ) <"> )
qdtext = <any TEXT except <">>

quoted-pair = "\" CHAR

*************************************************************************************************
3 Protocol Parameters

3.1 HTTP Version

The version of an HTTP message is indicated by an HTTP-Version field in the first line of the message.
       HTTP-Version   = "HTTP" "/" 1*DIGIT "." 1*DIGIT
Note that the major and minor numbers MUST be treated as separate integers and that each MAY be incremented higher than a single digit. Thus, HTTP/2.4 is a lower version than
HTTP/2.13, which in turn is lower than HTTP/12.3.

The HTTP version of an application is the highest HTTP version for which the application is at least conditionally compliant.


3.2 Uniform Resource Identifiers

The HTTP protocol does not place any a priori limit on the length of a URI.
Note: Servers ought to be cautious about depending on URI lengths above 255 bytes, because some older client or proxy implementations might not properly support these lengths.

http_URL = "http:" "//" host [ ":" port ] [ abs_path [ "?" query ]]


3.3 Date/Time Formats

       Sun, 06 Nov 1994 08:49:37 GMT  ; RFC 822, updated by RFC 1123
       Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
       Sun Nov  6 08:49:37 1994       ; ANSI C's asctime() format




HTTP-date    = rfc1123-date | rfc850-date | asctime-date
       rfc1123-date = wkday "," SP date1 SP time SP "GMT"
       rfc850-date  = weekday "," SP date2 SP time SP "GMT"
       asctime-date = wkday SP date3 SP time SP 4DIGIT
       date1        = 2DIGIT SP month SP 4DIGIT
                      ; day month year (e.g., 02 Jun 1982)
       date2        = 2DIGIT "-" month "-" 2DIGIT
                      ; day-month-year (e.g., 02-Jun-82)
       date3        = month SP ( 2DIGIT | ( SP 1DIGIT ))
                      ; month day (e.g., Jun  2)
       time         = 2DIGIT ":" 2DIGIT ":" 2DIGIT
                      ; 00:00:00 - 23:59:59
       wkday        = "Mon" | "Tue" | "Wed"
                    | "Thu" | "Fri" | "Sat" | "Sun"
       weekday      = "Monday" | "Tuesday" | "Wednesday"
                    | "Thursday" | "Friday" | "Saturday" | "Sunday"
       month        = "Jan" | "Feb" | "Mar" | "Apr"
                    | "May" | "Jun" | "Jul" | "Aug"
                    | "Sep" | "Oct" | "Nov" | "Dec"


3.4 Character Sets

HTTP uses the same definition of the term “character set” as that described for MIME.


3.5 Content Codings

gzip
compress
deflate
identity

3.6 Transfer Codings
Transfer-coding values are used to indicate an encoding transformation that has been, can be, or may need to be applied to an entity-body in order to ensure “safe transport” through the network.
This differs from a content coding in that the transfer-coding is a property of the message, not of the original entity.

3.7 Media Types
3.8 Product Tokens
3.9 Quality Values
3.10 Language Tags
3.11 Entity Tags
3.12 Range Units

*************************************************************************************************
4 HTTP Message

4.1 Message Types
HTTP-message   = Request | Response     ; HTTP/1.1 messages

generic-message = start-line
                  *(message-header CRLF)
                  CRLF
                  [ message-body ]
start-line      = Request-Line | Status-Line

4.2 Message Headers

       message-header = field-name ":" [ field-value ]
       field-name     = token
       field-value    = *( field-content | LWS )
       field-content  = <the OCTETs making up the field-value
                        and consisting of either *TEXT or combinations
                        of token, separators, and quoted-string>


The order in which header fields with differing field names are received is not significant.
However, it is “good practice” to send general-header fields first, followed by request-header or response-header fields, and ending with the entity-header fields.

4.3 Message Body

message-body = entity-body | <entity-body encoded as per Transfer-Encoding>

The message-body (if any) of an HTTP message is used to carry the entity-body associated with the request or response. The message-body differs from the entity-body only when a transfer-coding has been applied, as indicated by the Transfer-Encoding header field.

Transfer-Encoding is a property of the message, not of the entity, and thus MAY be added or removed by any application along the request/response chain.

4.4 Message Length

Content-Length 和 Transfer-Encoding的关系。

4.5 General Header Fields

general-header = Cache-Control          
                      | Connection            
                      | Date                 
                      | Pragma                 
                      | Trailer               
                      | Transfer-Encoding     
                      | Upgrade                
                      | Via                   
                      | Warning                


*************************************************************************************************                         
5 Request             
Request       = Request-Line    
                        *(  (general-header| request-header| entity-header ) CRLF)
                        CRLF
                        [ message-body ]   

5.1 Request-Line

Request-Line   = Method SP Request-URI SP HTTP-Version CRLF

       Method         = "OPTIONS"            
                      | "GET"                
                      | "HEAD"               
                      | "POST"               
                      | "PUT"                
                      | "DELETE"             
                      | "TRACE"              
                      | "CONNECT"            
                      | extension-method
       extension-method = token             

Request-URI    = "*" | absoluteURI | abs_path | authority

5.2 The Resource Identified by a Request
Request-URI和HOST的组合。

5.3 Request Header Fields

      
*************************************************************************************************                         
6 Response

After receiving and interpreting a request message, a server responds with an HTTP response message.
       Response      = Status-Line             
                       *(( general-header | response-header        | entity-header ) CRLF)
                       CRLF
                       [ message-body ]        
6.1 Status-Line
Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF

The first digit of the Status-Code defines the class of response. The last two digits do not have any
categorization role. There are 5 values for the first digit:
* 1xx: Informational - Request received, continuing process
* 2xx: Success - The action was successfully received, understood, and accepted
* 3xx: Redirection - Further action must be taken in order to complete the request
* 4xx: Client Error - The request contains bad syntax or cannot be fulfilled
* 5xx: Server Error - The server failed to fulfill an apparently valid request


6.2 Response Header Fields

*************************************************************************************************                         
7 Entity
Request and Response messages MAY transfer an entity if not otherwise restricted by the request method or response status code. An entity consists of entity-header fields and an entity-body, although some responses will only
include the entity-headers.

7.1 Entity Header Fields
7.2 Entity Body
entity-body    = *OCTET
*************************************************************************************************   
8 Connections        
8.1 Persistent Connections

Persistent Connections的优点.
1 By opening and closing fewer TCP connections, CPU time is saved in routers and hosts (clients, servers, proxies, gateways, tunnels, or caches), and memory used for TCP protocol control blocks can be saved in hosts.
2 HTTP requests and responses can be pipelined on a connection. Pipelining allows a client to make multiple requests without waiting for each response, allowing a single TCP connection to be used much more efficiently, with much lower elapsed time.
3 Network congestion is reduced by reducing the number of packets caused by TCP opens, and by allowing TCP sufficient time to determine the congestion state of the network.
4 Latency on subsequent requests is reduced since there is no time spent in TCP’s connection opening handshake.
5 HTTP can evolve more gracefully, since errors can be reported without the penalty of closing the TCP connection. Clients using future versions of HTTP might optimistically try a new feature, but if communicating with an older server, retry with old semantics after an error is reported.


A client that supports persistent connections MAY “pipeline” its requests (i.e., send multiple requests without waiting for each response). A server MUST send its responses to those requests in the same order that the requests were received.


8.2 Message Transmission Requirements          
*************************************************************************************************                         
9 Method Definitions
9.1 Safe and Idempotent Methods
Safe Methods 安全方法
Idempotent Methods 幂等性
9.2 OPTIONS
9.3 GET
The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI.
conditional GET 有条件的GET。
partial GET 部分GET。
9.4 HEAD
The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response.
GET的降级版。
This method is often used for testing hypertext links for validity, accessibility, and recent modification.
9.5 POST
The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line.
Annotation of existing resources;
Posting a message to a bulletin board, newsgroup, mailing list, or similar group of articles;
Providing a block of data, such as the result of submitting a form, to a data-handling process;
Extending a database through an append operation.
9.6 PUT
The PUT method requests that the enclosed entity be stored under the supplied Request-URI.

The fundamental difference between the POST and PUT requests is reflected in the different meaning of the Request-URI. The URI in a POST request identifies the resource that will handle the enclosed entity. That
resource might be a data-accepting process, a gateway to some other protocol, or a separate entity that accepts annotations. In contrast, the URI in a PUT request identifies the entity enclosed with the request -- the user agent
knows what URI is intended and the server MUST NOT attempt to apply the request to some other resource. If the server desires that the request be applied to a different URI, it MUST send a 301 (Moved Permanently) response; the
user agent MAY then make its own decision regarding whether or not to redirect the request.
9.7 DELETE
The DELETE method requests that the origin server delete the resource identified by the Request-URI.
9.8 TRACE
The TRACE method is used to invoke a remote, application-layer loop-back of the request message.
TRACE allows the client to see what is being received at the other end of the request chain and use that data for testing or diagnostic information.
9.9 CONNECT
*************************************************************************************************                         
10 Status Code Definitions

10.2.1  200 OK
The request has succeeded. The information returned with the response is dependent on the method used in the request.

10.3.3  302 Found
The requested resource resides temporarily under a different URI.

10.4.1  400 Bad Request
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.

10.4.4  403 Forbidden
The server understood the request, but is refusing to fulfill it.

10.4.5  404 Not Found
The server has not found anything matching the Request-URI.

10.5.1  500 Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling the request.

10.5.6  505 HTTP Version Not Supported
The server does not support, or refuses to support, the HTTP protocol version that was used in the request message.
*************************************************************************************************                         
*************************************************************************************************                                   
分享到:
评论

相关推荐

    rfc2616/HTTP/1.1中文版

    ### HTTP/1.1协议详解(基于RFC 2616) #### 协议概述 《rfc2616/HTTP/1.1中文版》详细介绍了HTTP/1.1协议,它是对之前的RFC 2068的修订版。HTTP/1.1作为互联网上应用最为广泛的应用层协议之一,主要负责客户端与...

    RFC 2616 Hypertext Transfer Protocol -- HTTP/1.1

    **RFC 2616**,即《Hypertext Transfer Protocol -- HTTP/1.1》,是超文本传输协议HTTP/1.1的标准文档。该文档由一组作者(包括R. Fielding、J. Gettys、J. Mogul等人)共同完成,并于1999年6月发布。HTTP/1.1是一种...

    RFC 2616 HTTP 1.1 超文本传输协议(中文版有目录) pdf

    - **定义与背景**:《RFC 2616 HTTP 1.1 超文本传输协议》是互联网标准之一,由R. Fielding等人编写,首次发布于1999年6月。该文档详细介绍了HTTP/1.1协议的各个方面,是对之前版本RFC 2068的更新和完善。 - **目的*...

    rfc2616 http协议中文

    《深入解析RFC2616 HTTP/1.1协议》 一、引言与目的 RFC2616,即Request for Comments 2616,由R. Fielding、J. Gettys、J.C. Mogul、H. Frystyk、L. Masinter、P. Leach和T. Berners-Lee等人共同撰写,于1999年6月...

    http/1.1协议2014年最新版

    HTTP/1.1协议是在RFC2616的基础上,经过多次修订,最终由RFC7230至7235系列文档定义。 RFC文档是由互联网工程任务组(IETF)发布的正式文件,它详细记录了互联网标准、协议及协议扩展的说明。RFC7230至7235文档取代了...

    RFC2616(HTTP1.1)协议文档

    ### 超文本传输协议(HTTP/1.1)—— RFC2616 核心知识点解析 #### 一、概述 《超文本传输协议(HTTP/1.1)》作为互联网领域的一项重要标准,由IETF(Internet Engineering Task Force,互联网工程任务组)发布,...

    超文本传输协议-HTTP/1.1

    ### 超文本传输协议-HTTP/1.1 关键知识点 #### 1. HTTP/1.1 概述 - **定义**:超文本传输协议(HyperText Transfer Protocol,简称HTTP)是一种分布式、协作式的、超媒体信息系统,主要用于客户端和服务端之间的...

    Http_1.1Specification

    HTTP是超文本传输协议(HyperText Transfer Protocol)的缩写,而HTTP/1.1作为其版本号,代表了该协议在1999年的更新版本,是RFC2068的修订版。 在了解HTTP/1.1协议之前,有必要先了解其在互联网社区中的地位。RFC...

    http-1.1中文文档(115页word格式)

    超文本传输协议(HTTP,Hypertext Transfer Protocol)是互联网上应用最为广泛的一种网络协议,它的1.1版本(HTTP/1.1)是目前最常用的标准,它在RFC 2068的基础上进行了修订和完善。这个文档,"HTTP/1.1中文文档...

    http1.1 http1.1

    **HTTP/1.1**是超文本传输协议(Hypertext Transfer Protocol)的一个版本,它由互联网工程任务组(IETF)制定,并在RFC 2616文档中进行了详细定义。自1999年发布以来,HTTP/1.1已成为现代网络应用的基础之一,为...

    rfc2616中文版

    《rfc2616中文版》是一份详尽的技术文档,主要介绍了HTTP/1.1协议的标准,由Fielding等人编写,首次发布于1999年6月。这份文档被视为互联网技术领域的重要资源,它对超文本传输协议(HTTP)进行了深度解析,特别是其在...

    rfc2616 中文翻译完全版本

    《rfc2616中文翻译完全版本》深入解析HTTP/1.1协议的核心要点 在互联网技术领域,HTTP(超文本传输协议)是Web应用的基础,而RFC2616文档则是定义HTTP/1.1协议标准的重要文献。本文旨在通过对《rfc2616中文翻译完全...

    HTTP协议1.1 RFC2616中文说明

    ### HTTP协议1.1 RFC2616中文说明知识点概览 #### 1. 引言 **1.1 目的** 超文本传输协议(HTTP)作为一种应用层协议,最初设计目的是为了支持分布式、协作式的超媒体信息系统。HTTP/1.1作为其最新的版本,在1990年...

    已解锁-RFC2616(HTTP)中文版

    ### HTTP/1.1协议详解:RFC2616核心知识点 #### 一、协议概述与定位 **超文本传输协议(HTTP)**是互联网上应用最广泛的一种网络协议,主要用于从万维网服务器传输超文本到本地浏览器的传送协议。HTTP/1.1作为HTTP...

Global site tag (gtag.js) - Google Analytics