LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 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 client implementation. See RFC 2616. | 5 // HTTP client implementation. See RFC 2616. |
6 //· | 6 //· |
7 // This is the low-level Transport implementation of RoundTripper. | 7 // This is the low-level Transport implementation of RoundTripper. |
8 // The high-level interface is in client.go. | 8 // The high-level interface is in client.go. |
9 | 9 |
10 package http | 10 package http |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 case cm.targetScheme == "http": | 325 case cm.targetScheme == "http": |
326 pconn.isProxy = true | 326 pconn.isProxy = true |
327 if pa != "" { | 327 if pa != "" { |
328 pconn.mutateHeaderFunc = func(h Header) { | 328 pconn.mutateHeaderFunc = func(h Header) { |
329 h.Set("Proxy-Authorization", pa) | 329 h.Set("Proxy-Authorization", pa) |
330 } | 330 } |
331 } | 331 } |
332 case cm.targetScheme == "https": | 332 case cm.targetScheme == "https": |
333 connectReq := &Request{ | 333 connectReq := &Request{ |
334 Method: "CONNECT", | 334 Method: "CONNECT", |
335 » » » URL: &url.URL{RawPath: cm.targetAddr}, | 335 » » » URL: {RawPath: cm.targetAddr}, |
336 Host: cm.targetAddr, | 336 Host: cm.targetAddr, |
337 Header: make(Header), | 337 Header: make(Header), |
338 } | 338 } |
339 if pa != "" { | 339 if pa != "" { |
340 connectReq.Header.Set("Proxy-Authorization", pa) | 340 connectReq.Header.Set("Proxy-Authorization", pa) |
341 } | 341 } |
342 connectReq.Write(conn) | 342 connectReq.Write(conn) |
343 | 343 |
344 // Read response. | 344 // Read response. |
345 // Okay to use and discard buffered reader here, because | 345 // Okay to use and discard buffered reader here, because |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 | 731 |
732 // discardOnCloseReadCloser consumes all its input on Close. | 732 // discardOnCloseReadCloser consumes all its input on Close. |
733 type discardOnCloseReadCloser struct { | 733 type discardOnCloseReadCloser struct { |
734 io.ReadCloser | 734 io.ReadCloser |
735 } | 735 } |
736 | 736 |
737 func (d *discardOnCloseReadCloser) Close() error { | 737 func (d *discardOnCloseReadCloser) Close() error { |
738 io.Copy(ioutil.Discard, d.ReadCloser) // ignore errors; likely invalid o
r already closed | 738 io.Copy(ioutil.Discard, d.ReadCloser) // ignore errors; likely invalid o
r already closed |
739 return d.ReadCloser.Close() | 739 return d.ReadCloser.Close() |
740 } | 740 } |
LEFT | RIGHT |