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

http.Get Fails with URIs that include embedded username:password #407

Closed
ajstarks opened this issue Dec 10, 2009 · 2 comments
Closed

http.Get Fails with URIs that include embedded username:password #407

ajstarks opened this issue Dec 10, 2009 · 2 comments

Comments

@ajstarks
Copy link
Contributor

Before filing a bug, please check whether it has been fixed since
the latest release: run "hg pull -u" and retry what you did to
reproduce the problem.  Thanks.

What steps will reproduce the problem?
1. attempt to http.Get on a URI with embedded username/password such as:
   

http://username:password@api.twitter.com/1/ajstarks/msm/members.json


What is the expected output? What do you see instead?

GET fails with a status code of 401 instead of the expected 200


What is your $GOOS?  $GOARCH?

darwin amd64


Which revision are you using?  (hg identify)

7929874a70ae+ release

Please provide any additional information below.

(substitute username:password with a valid account)
 
$ curl http://username:password@api.twitter.com/1/ajstarks/msm/members.json 

works,

but 

package main

import (
    "fmt";
    "http";
    "io/ioutil";
)


func printContent(s string) {
    r, final, err := http.Get(s);
    
    if r.StatusCode == 200 {
        var b []byte;
        if err == nil {
            b, err = ioutil.ReadAll(r.Body);
            fmt.Printf(string(b));
            r.Body.Close();
        }
    } else fmt.Printf("final: %v, err: %v (%v)\n", final, err, r.StatusCode);
}


func main() {
    
    printContent("http://username:password@api.twitter.com/1/ajstarks/msm/members.json";);
        printContent("http://search.twitter.com/search.json?q=%23golang";);
}


returns: 

final: http://username:password@api.twitter.com/1/ajstarks/msm/members.json, err:
<nil> (401)

.....content from second URI....
@krasin
Copy link

krasin commented Dec 14, 2009

Comment 1:

Fix is under review: http://golang.org/cl/176076

@rsc
Copy link
Contributor

rsc commented Dec 16, 2009

Comment 2:

This issue was closed by revision 8e2608e.

Status changed to Fixed.

Merged into issue #-.

@ajstarks ajstarks added the fixed label Dec 16, 2009
@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

4 participants