LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // HTTP Response reading and parsing. | 5 // HTTP Response reading and parsing. |
6 | 6 |
7 package http | 7 package http |
8 | 8 |
9 import ( | 9 import ( |
10 "bufio" | 10 "bufio" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 // Close records whether the header directed that the connection be | 59 // Close records whether the header directed that the connection be |
60 // closed after reading Body. The value is advice for clients: neither | 60 // closed after reading Body. The value is advice for clients: neither |
61 // ReadResponse nor Response.Write ever closes a connection. | 61 // ReadResponse nor Response.Write ever closes a connection. |
62 Close bool | 62 Close bool |
63 | 63 |
64 // Trailer maps trailer keys to values, in the same | 64 // Trailer maps trailer keys to values, in the same |
65 // format as the header. | 65 // format as the header. |
66 Trailer Header | 66 Trailer Header |
67 | 67 |
68 » // The most recent Request that was sent to obtain this Response. | 68 » // The Request that was sent to obtain this Response. |
69 // Request's Body is nil (having already been consumed). | 69 // Request's Body is nil (having already been consumed). |
70 // This is only populated for Client requests. | 70 // This is only populated for Client requests. |
71 Request *Request | 71 Request *Request |
72 } | 72 } |
73 | 73 |
74 // ReadResponse reads and returns an HTTP response from r. The | 74 // ReadResponse reads and returns an HTTP response from r. The |
75 // req parameter specifies the Request that corresponds to | 75 // req parameter specifies the Request that corresponds to |
76 // this Response. Clients must call resp.Body.Close when finished | 76 // this Response. Clients must call resp.Body.Close when finished |
77 // reading resp.Body. After that call, clients can inspect | 77 // reading resp.Body. After that call, clients can inspect |
78 // resp.Trailer to find key/value pairs included in the response | 78 // resp.Trailer to find key/value pairs included in the response |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 | 209 |
210 // Write body and trailer | 210 // Write body and trailer |
211 err = tw.WriteBody(w) | 211 err = tw.WriteBody(w) |
212 if err != nil { | 212 if err != nil { |
213 return err | 213 return err |
214 } | 214 } |
215 | 215 |
216 // Success | 216 // Success |
217 return nil | 217 return nil |
218 } | 218 } |
LEFT | RIGHT |