Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http/client.go - Client.CheckRedirect does not have the claimed error behavior #3724

Closed
gopherbot opened this issue Jun 11, 2012 · 3 comments

Comments

@gopherbot
Copy link
Contributor

by krueger@google.com:

According to the documentation for http.Client:

    // CheckRedirect specifies the policy for handling redirects.
    // If CheckRedirect is not nil, the client calls it before
    // following an HTTP redirect. The arguments req and via
    // are the upcoming request and the requests made already,
    // oldest first. If CheckRedirect returns an error, the client
    // returns that error instead of issue the Request req.

The code does not actually do what this comment says.

The doFollowingRedirects method, and thus the Do method, do not actually return _that
error_ (i.e. the error object returned by CheckRedirect).  It returns a new url.Error
whose Err field is the error returned by CheckRedirect.

I'm not sure what is the desirable behavior in light of the rest of the code base ...
but it seems to me that what is described in the comment is worthwhile, so that client
code can set a specific error object (or type) in CheckRedirect and check for it as the
error return.  Client code could then just do an == comparison for the error set by
CheckRedirect, and wouldn't need to import "net/url" in order to check the
type of the url.Error.
@rsc
Copy link
Contributor

rsc commented Jun 11, 2012

Comment 1:

We should fix the comment.

Owner changed to @bradfitz.

Status changed to Accepted.

@bradfitz
Copy link
Contributor

Comment 2:

http://golang.org/cl/6294093

@bradfitz
Copy link
Contributor

Comment 3:

This issue was closed by revision 93b7d1b.

Status changed to Fixed.

bradfitz added a commit that referenced this issue May 11, 2015

Verified

This commit was signed with the committer’s verified signature.
myitcv Paul Jolly
««« backport 60041e23de38
net/http: fix doc inaccuracy and typo; tighten test

Note url.Error wrapping, and s/issue/issuing/.

Fixes #3724

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6294093

»»»
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants