`
hideto
  • 浏览: 2682896 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

HTTP1.1 Notes 3, HTTP Message

阅读更多
Message Types
        HTTP-message   = Request | Response     ; HTTP/1.1 messages

HTTP messages consist of requests from client to server and responses from server to client
Request and Response messages use the generic message format of RFC 822 for transferring entities

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

In the interest of robustness, servers SHOULD ignore any empty line(s) received where a Request-Line is expected
HTTP/1.1 client MUST NOT preface or follow a request with an extra CRLF

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>
HTTP header fields, which include general-header, request-header, response-header, and entity-header fields, follow the same generic format as that given in Section 3.1 of RFC 822
Each header field consists of a name followed by a colon (":") and the field value

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
A message-body MUST NOT be included in a request if the specification of the request method does not allow sending an entity-body in requests

For response messages, whether or not a message-body is included with a message is dependent on both the request method and the response status code
All responses to the HEAD request method MUST NOT include a message-body, even though the presence of entity-header fields might lead one to believe they do
All 1xx (informational), 204 (no content), and 304 (not modified) responses MUST NOT include a message-body
All other responses do include a message-body, although it MAY be of zero length.

Message Length
The transfer-length of a message is the length of the message-body as it appears in the message after any transfer-codings have been applied

If a request contains a message-body and a Content-Length is not given, the server SHOULD respond with 400 (bad request) if it cannot determine the length of the message, or with 411 (length required) if it wishes to insist on receiving a valid Content-Length

Messages MUST NOT include both a Content-Length header field and a non-identity transfer-coding
If the message does include a non-identity transfer-coding, the Content-Length MUST be ignored

When a Content-Length is given in a message where a message-body is allowed, its field value MUST exactly match the number of OCTETs in the message-body
HTTP/1.1 user agents MUST notify the user when an invalid length is received and detected

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

New or experimental header fields may be given the semantics of general header fields if all parties in the communication recognize them to be general-header fields
Unrecognized header fields are treated as entity-header fields

Example
D:\projects\maui>curl -i http://www.baidu.com
HTTP/1.1 200 OK
Date: Fri, 26 Dec 2008 02:54:34 GMT
Server: BWS/1.0
Content-Length: 4064
Content-Type: text/html
Cache-Control: private
Expires: Fri, 26 Dec 2008 02:54:34 GMT
Set-Cookie: BAIDUID=8738C03034DA31AB6005581059479804:FG=1; expires=Fri, 26-Dec-
8 02:54:34 GMT; path=/; domain=.baidu.com
P3P: CP=" OTI DSP COR IVA OUR IND COM "

<html><head><meta http-equiv=Content-Type content="text/html;charset=gb2312"><ti
tle>百度一下,你就知道      </title>
......

可以看到Message Header和Message Body之间有一个CRLF
分享到:
评论

相关推荐

    Django 1.1 Testing and Debugging.pdf

    Coding custom error message and placement 226 Debug page #5: Another TemplateSyntaxError 229 Fixing the second TemplateSyntaxError 232 Summary 233 Chapter 8: When Problems Hide: Getting More ...

    ACR122U_驱动

    3. Update ACSCCID driver to v1.1.6.5. v1.1.2.0 (27/2/2010) 1. Update UI. 4. File Contents ---------------- | ReadMe.txt | Setup.exe | +---redist | InstMsiW.exe | \---x86 ACR38_100_122_PCSC_...

    ZendFramework中文文档

    Notes Regarding Cascading Operations 11. Zend_Debug 11.1. 输出变量的值 (Dumping Variables) 12. Zend_Exception 12.1. 使用“异常” 13. Zend_Feed 13.1. 介绍 13.2. 导入Feeds 13.2.1. 定制 feeds ...

    python3.6.5参考手册 chm

    PEP 314: Metadata for Python Software Packages v1.1 PEP 328: Absolute and Relative Imports PEP 338: Executing Modules as Scripts PEP 341: Unified try/except/finally PEP 342: New Generator Features...

    ak2新版内核AKAIO1.5

    (Use the v1.1 rom as v1.0 will not work anymore). + Unicode font loads on a per-ROM basis - Default font is "kochi-mincho-subst.pcf" in /__aio/fonts directory, old unicode font removed (was 2x the ...

    Network Security: Private Communication in a Public World, Second Edition

    Section 1.1. Roadmap to the Book Section 1.2. What Type of Book Is This? Section 1.3. Terminology Section 1.4. Notation Section 1.5. Primer on Networking Section 1.6. Active vs. Passive ...

    程序语言设计原理习题解答

    1.1 Reasons for Studying Concepts of Programming Languages 2 1.2 Programming Domains 5 1.3 Language Evaluation Criteria 7 1.4 Influences on Language Design 20 1.5 Language Categories 23 1.6 ...

    java-servlet-api.doc

    你可以从http://info.internet.isi.edu/7c/in-notes/rfc/.cache找到下面提到的所有这些RFC规范。 RFC1738统一资源定位器(URL) RFC1808相关统一资源定位器 RFC1945超文本传输协议--HTTP/1.0 RFC2045多用途Internet...

    axis2-1.4.1-bin.zip axis2-1.4.1-war.zip

    它支持多种协议,包括SOAP 1.1、SOAP 1.2、REST、MTOM(Message Transmission Optimization Mechanism)和SwA(SOAP with Attachments)。 2. **axis2-1.4.1-bin.zip**:这个压缩包是Apache Axis2的二进制发行版,...

    axis(java webserice包)

    - **MTOM/XOP**:Message Transmission Optimization Mechanism和XML-binary Optimized Packaging是Axis2支持的优化机制,用于高效传输二进制数据,如图片或大文件。 - **部署和管理**:Axis提供了丰富的部署选项,...

    TMS Pack for FireMonkey2.3.0.1

    Fixed : Issue with debug message in TTMSFMXGrid v1.8.0.5 Fixed : Issue with dblclick focusing issue in TTMSFMXGrid Improved : comment popup in cell configurable in TTMSFMXGridCell v1.8.0.6 ...

    BC35中文AT指令MQTT指令COAP指令.zip

    此外,Quectel_BC35-G-JB_Firmware_Release_Notes_V0106.pdf提供了BC35-G模块固件版本V0106的更新日志,包括新增功能、性能改进和已知问题修复等信息,这对于开发者来说是升级和维护设备时的重要参考。 最后,...

    Python程序设计(第二版).chm

    Section 1.1. "And Now for Something Completely Different" Section 1.2. The Life of Python Section 1.3. The Compulsory Features List Section 1.4. What's Python Good For? Section 1.5. What's ...

    外文翻译 stus MVC

    Struts is an MVC implementation that uses Servlets 2.2 and JSP 1.1 tags, from the J2EE specifications, as part of the implementation. You may never implement a system with Struts, but looking at ...

    occam一维反演

    C CONSTABLE, 1992: OCCAM DISTRIBUTION NOTES. C C REVISION HISTORY: C MARCH 1986, (VERSION 1.2) C OCTOBER 1987, (VERSION 1.3) C AUGUST 1988, (VERSION 1.4) C JANUARY 1989 (WITH THANKS TO C.DEGROOT-...

    Oracle sqldeveloper without jdk (win+linux)

    Release Notes 完整版下载:http://www.oracle.com/technology/global/cn/software/products/sql/index.html 1. Known Issues 1.1 General - Print prints only one page that is a truncation of the current ...

    8-07-14_MegaCLI for linux_windows

    LSIP200232870 (DFCT) Add a Gen2 to Gen3 toggle function and a check for the PCI speed to MegaSCU/CLI [ PR : LSIP200231423 ] LSIP200232927 (DFCT) Port PR 198414 to MR5.4 (Headless Boot) ...

    MS-DOS 5.0

    NOTES ON MS-DOS VERSION 5.0 =========================== In this file the following topics are covered: 1. Introduction 2. Solving Setup Problems 2.1 Priam and Everex Hard Disks 2.2 SyQuest ...

    MySQL 5.6 Reference Manual

    Preface, Notes, Licenses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....

Global site tag (gtag.js) - Google Analytics