@@ -37,21 +37,20 @@ import (
37
37
// When following redirects, the Client will forward all headers set on the
38
38
// initial Request except:
39
39
//
40
- // * when forwarding sensitive headers like "Authorization",
41
- // "WWW-Authenticate", and "Cookie" to untrusted targets.
42
- // These headers will be ignored when following a redirect to a domain
43
- // that is not a subdomain match or exact match of the initial domain.
44
- // For example, a redirect from "foo.com" to either "foo.com" or "sub.foo.com"
45
- // will forward the sensitive headers, but a redirect to "bar.com" will not.
46
- //
47
- // * when forwarding the "Cookie" header with a non-nil cookie Jar.
48
- // Since each redirect may mutate the state of the cookie jar,
49
- // a redirect may possibly alter a cookie set in the initial request.
50
- // When forwarding the "Cookie" header, any mutated cookies will be omitted,
51
- // with the expectation that the Jar will insert those mutated cookies
52
- // with the updated values (assuming the origin matches).
53
- // If Jar is nil, the initial cookies are forwarded without change.
54
- //
40
+ // - when forwarding sensitive headers like "Authorization",
41
+ // "WWW-Authenticate", and "Cookie" to untrusted targets.
42
+ // These headers will be ignored when following a redirect to a domain
43
+ // that is not a subdomain match or exact match of the initial domain.
44
+ // For example, a redirect from "foo.com" to either "foo.com" or "sub.foo.com"
45
+ // will forward the sensitive headers, but a redirect to "bar.com" will not.
46
+ //
47
+ // - when forwarding the "Cookie" header with a non-nil cookie Jar.
48
+ // Since each redirect may mutate the state of the cookie jar,
49
+ // a redirect may possibly alter a cookie set in the initial request.
50
+ // When forwarding the "Cookie" header, any mutated cookies will be omitted,
51
+ // with the expectation that the Jar will insert those mutated cookies
52
+ // with the updated values (assuming the origin matches).
53
+ // If Jar is nil, the initial cookies are forwarded without change.
55
54
type Client struct {
56
55
// Transport specifies the mechanism by which individual
57
56
// HTTP requests are made.
@@ -344,11 +343,11 @@ func basicAuth(username, password string) string {
344
343
// the following redirect codes, Get follows the redirect, up to a
345
344
// maximum of 10 redirects:
346
345
//
347
- // 301 (Moved Permanently)
348
- // 302 (Found)
349
- // 303 (See Other)
350
- // 307 (Temporary Redirect)
351
- // 308 (Permanent Redirect)
346
+ // 301 (Moved Permanently)
347
+ // 302 (Found)
348
+ // 303 (See Other)
349
+ // 307 (Temporary Redirect)
350
+ // 308 (Permanent Redirect)
352
351
//
353
352
// An error is returned if there were too many redirects or if there
354
353
// was an HTTP protocol error. A non-2xx response doesn't cause an
@@ -373,11 +372,11 @@ func (c *Client) Get(url string) (r *Response, err error) {
373
372
// following redirect codes, Get follows the redirect after calling the
374
373
// Client's CheckRedirect function:
375
374
//
376
- // 301 (Moved Permanently)
377
- // 302 (Found)
378
- // 303 (See Other)
379
- // 307 (Temporary Redirect)
380
- // 308 (Permanent Redirect)
375
+ // 301 (Moved Permanently)
376
+ // 302 (Found)
377
+ // 303 (See Other)
378
+ // 307 (Temporary Redirect)
379
+ // 308 (Permanent Redirect)
381
380
//
382
381
// An error is returned if the Client's CheckRedirect function fails
383
382
// or if there was an HTTP protocol error. A non-2xx response doesn't
@@ -770,11 +769,11 @@ func (c *Client) PostForm(url string, data url.Values) (resp *Response, err erro
770
769
// the following redirect codes, Head follows the redirect, up to a
771
770
// maximum of 10 redirects:
772
771
//
773
- // 301 (Moved Permanently)
774
- // 302 (Found)
775
- // 303 (See Other)
776
- // 307 (Temporary Redirect)
777
- // 308 (Permanent Redirect)
772
+ // 301 (Moved Permanently)
773
+ // 302 (Found)
774
+ // 303 (See Other)
775
+ // 307 (Temporary Redirect)
776
+ // 308 (Permanent Redirect)
778
777
//
779
778
// Head is a wrapper around DefaultClient.Head
780
779
func Head (url string ) (resp * Response , err error ) {
@@ -785,11 +784,11 @@ func Head(url string) (resp *Response, err error) {
785
784
// following redirect codes, Head follows the redirect after calling the
786
785
// Client's CheckRedirect function:
787
786
//
788
- // 301 (Moved Permanently)
789
- // 302 (Found)
790
- // 303 (See Other)
791
- // 307 (Temporary Redirect)
792
- // 308 (Permanent Redirect)
787
+ // 301 (Moved Permanently)
788
+ // 302 (Found)
789
+ // 303 (See Other)
790
+ // 307 (Temporary Redirect)
791
+ // 308 (Permanent Redirect)
793
792
func (c * Client ) HeadWithHost (url , host string ) (resp * Response , err error ) {
794
793
req , err := NewRequestWithHost ("HEAD" , url , host , nil )
795
794
if err != nil {
@@ -803,9 +802,9 @@ func (c *Client) Head(url string) (resp *Response, err error) {
803
802
}
804
803
805
804
// cancelTimerBody is an io.ReadCloser that wraps rc with two features:
806
- // 1) on Read error or close, the stop func is called.
807
- // 2) On Read failure, if reqDidTimeout is true, the error is wrapped and
808
- // marked as net.Error that hit its timeout.
805
+ // 1. on Read error or close, the stop func is called.
806
+ // 2. On Read failure, if reqDidTimeout is true, the error is wrapped and
807
+ // marked as net.Error that hit its timeout.
809
808
type cancelTimerBody struct {
810
809
stop func () // stops the time.Timer waiting to cancel the request
811
810
rc io.ReadCloser
0 commit comments