发布日期:2014-03-07 14:03:26

如何定义一个HTTP Request呢?在RFC2616的第五章定义了HTTP请求的格式。请参考官网

RFC2616对请求的定义摘要:

请求的定义:

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

请求行的定义:

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

请求方法的种类:

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

如何定义URI:

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

请求头字段列表:

request-header = Accept                
                      | Accept-Charset          
                      | Accept-Encoding        
                      | Accept-Language      
                      | Authorization     
                      | Expect              
                      | From                  
                      | Host                 
                      | If-Match            
                      | If-Modified-Since       
                      | If-None-Match           
                      | If-Range              
                      | If-Unmodified-Since    
                      | Max-Forwards          
                      | Proxy-Authorization    
                      | Range             
                      | Referer               
                      | TE                   
                      | User-Agent               

 

发表评论