Debian Codegraph @

third_party/python/aiohttp/vendor/llhttp/test/response/content-length.md

raw
1 Content-Length header
2 =====================
3
4 ## Response without `Content-Length`, but with body
5
6 The client should wait for the server's EOF. That is, when
7 `Content-Length` is not specified, and `Connection: close`, the end of body is
8 specified by the EOF.
9
10 _(Compare with APACHEBENCH_GET)_
11
12 <!-- meta={"type": "response"} -->
13 ```http
14 HTTP/1.1 200 OK
15 Date: Tue, 04 Aug 2009 07:59:32 GMT
16 Server: Apache
17 X-Powered-By: Servlet/2.5 JSP/2.1
18 Content-Type: text/xml; charset=utf-8
19 Connection: close
20
21 <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
22 <SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">\n\
23 <SOAP-ENV:Body>\n\
24 <SOAP-ENV:Fault>\n\
25 <faultcode>SOAP-ENV:Client</faultcode>\n\
26 <faultstring>Client Error</faultstring>\n\
27 </SOAP-ENV:Fault>\n\
28 </SOAP-ENV:Body>\n\
29 </SOAP-ENV:Envelope>
30 ```
31
32 ```log
33 off=0 message begin
34 off=5 len=3 span[version]="1.1"
35 off=8 version complete
36 off=13 len=2 span[status]="OK"
37 off=17 status complete
38 off=17 len=4 span[header_field]="Date"
39 off=22 header_field complete
40 off=23 len=29 span[header_value]="Tue, 04 Aug 2009 07:59:32 GMT"
41 off=54 header_value complete
42 off=54 len=6 span[header_field]="Server"
43 off=61 header_field complete
44 off=62 len=6 span[header_value]="Apache"
45 off=70 header_value complete
46 off=70 len=12 span[header_field]="X-Powered-By"
47 off=83 header_field complete
48 off=84 len=19 span[header_value]="Servlet/2.5 JSP/2.1"
49 off=105 header_value complete
50 off=105 len=12 span[header_field]="Content-Type"
51 off=118 header_field complete
52 off=119 len=23 span[header_value]="text/xml; charset=utf-8"
53 off=144 header_value complete
54 off=144 len=10 span[header_field]="Connection"
55 off=155 header_field complete
56 off=156 len=5 span[header_value]="close"
57 off=163 header_value complete
58 off=165 headers complete status=200 v=1/1 flags=2 content_length=0
59 off=165 len=42 span[body]="<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
60 off=207 len=1 span[body]=lf
61 off=208 len=80 span[body]="<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">"
62 off=288 len=1 span[body]=lf
63 off=289 len=17 span[body]=" <SOAP-ENV:Body>"
64 off=306 len=1 span[body]=lf
65 off=307 len=20 span[body]=" <SOAP-ENV:Fault>"
66 off=327 len=1 span[body]=lf
67 off=328 len=45 span[body]=" <faultcode>SOAP-ENV:Client</faultcode>"
68 off=373 len=1 span[body]=lf
69 off=374 len=46 span[body]=" <faultstring>Client Error</faultstring>"
70 off=420 len=1 span[body]=lf
71 off=421 len=21 span[body]=" </SOAP-ENV:Fault>"
72 off=442 len=1 span[body]=lf
73 off=443 len=18 span[body]=" </SOAP-ENV:Body>"
74 off=461 len=1 span[body]=lf
75 off=462 len=20 span[body]="</SOAP-ENV:Envelope>"
76 ```
77
78 ## Content-Length-X
79
80 The header that starts with `Content-Length*` should not be treated as
81 `Content-Length`.
82
83 <!-- meta={"type": "response"} -->
84 ```http
85 HTTP/1.1 200 OK
86 Content-Length-X: 0
87 Transfer-Encoding: chunked
88
89 2
90 OK
91 0
92
93
94 ```
95
96 ```log
97 off=0 message begin
98 off=5 len=3 span[version]="1.1"
99 off=8 version complete
100 off=13 len=2 span[status]="OK"
101 off=17 status complete
102 off=17 len=16 span[header_field]="Content-Length-X"
103 off=34 header_field complete
104 off=35 len=1 span[header_value]="0"
105 off=38 header_value complete
106 off=38 len=17 span[header_field]="Transfer-Encoding"
107 off=56 header_field complete
108 off=57 len=7 span[header_value]="chunked"
109 off=66 header_value complete
110 off=68 headers complete status=200 v=1/1 flags=208 content_length=0
111 off=71 chunk header len=2
112 off=71 len=2 span[body]="OK"
113 off=75 chunk complete
114 off=78 chunk header len=0
115 off=80 chunk complete
116 off=80 message complete
117 ```
118
119 ## Content-Length reset when no body is received
120
121 <!-- meta={"type": "response", "skipBody": true} -->
122 ```http
123 HTTP/1.1 200 OK
124 Content-Length: 123
125
126 HTTP/1.1 200 OK
127 Content-Length: 456
128
129
130 ```
131
132 ```log
133 off=0 message begin
134 off=5 len=3 span[version]="1.1"
135 off=8 version complete
136 off=13 len=2 span[status]="OK"
137 off=17 status complete
138 off=17 len=14 span[header_field]="Content-Length"
139 off=32 header_field complete
140 off=33 len=3 span[header_value]="123"
141 off=38 header_value complete
142 off=40 headers complete status=200 v=1/1 flags=20 content_length=123
143 off=40 skip body
144 off=40 message complete
145 off=40 reset
146 off=40 message begin
147 off=45 len=3 span[version]="1.1"
148 off=48 version complete
149 off=53 len=2 span[status]="OK"
150 off=57 status complete
151 off=57 len=14 span[header_field]="Content-Length"
152 off=72 header_field complete
153 off=73 len=3 span[header_value]="456"
154 off=78 header_value complete
155 off=80 headers complete status=200 v=1/1 flags=20 content_length=456
156 off=80 skip body
157 off=80 message complete
158 ```