OLD | NEW |
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 // Trailer maps trailer keys to values, in the same | 70 // Trailer maps trailer keys to values, in the same |
71 // format as the header. | 71 // format as the header. |
72 Trailer Header | 72 Trailer Header |
73 | 73 |
74 // The Request that was sent to obtain this Response. | 74 // The Request that was sent to obtain this Response. |
75 // Request's Body is nil (having already been consumed). | 75 // Request's Body is nil (having already been consumed). |
76 // This is only populated for Client requests. | 76 // This is only populated for Client requests. |
77 Request *Request | 77 Request *Request |
78 | 78 |
79 » // TLS allows information about the TLS connection on which the | 79 » // TLS contains information about the TLS connection on which the |
80 » // response was received. The Transport in this package sets the field | 80 » // response was received. It is nil for unencrypted responses. |
81 » // for TLS-enabled connections before returning the Response otherwise | 81 » // The pointer is shared between responses and should not be |
82 » // it leaves the field nil. | 82 » // modified. |
83 TLS *tls.ConnectionState | 83 TLS *tls.ConnectionState |
84 } | 84 } |
85 | 85 |
86 // Cookies parses and returns the cookies set in the Set-Cookie headers. | 86 // Cookies parses and returns the cookies set in the Set-Cookie headers. |
87 func (r *Response) Cookies() []*Cookie { | 87 func (r *Response) Cookies() []*Cookie { |
88 return readSetCookies(r.Header) | 88 return readSetCookies(r.Header) |
89 } | 89 } |
90 | 90 |
91 var ErrNoLocation = errors.New("http: no Location header in response") | 91 var ErrNoLocation = errors.New("http: no Location header in response") |
92 | 92 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 | 235 |
236 // Write body and trailer | 236 // Write body and trailer |
237 err = tw.WriteBody(w) | 237 err = tw.WriteBody(w) |
238 if err != nil { | 238 if err != nil { |
239 return err | 239 return err |
240 } | 240 } |
241 | 241 |
242 // Success | 242 // Success |
243 return nil | 243 return nil |
244 } | 244 } |
OLD | NEW |