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.Request.Write ignores Proto{Major,Minor} #910

Closed
gopherbot opened this issue Jul 9, 2010 · 6 comments
Closed

http.Request.Write ignores Proto{Major,Minor} #910

gopherbot opened this issue Jul 9, 2010 · 6 comments

Comments

@gopherbot
Copy link
Contributor

by temotor:

What steps will reproduce the problem?

    req := new(http.Request)
    req.URL = http.ParseURL("http://localhost/";)
    req.ProtoMajor, req.ProtoMinor = 1, 0

    // debug
    dump, _ := http.DumpRequest(req, true)
    print(string(dump))

What is the expected output?

GET / HTTP/1.0
...

What do you see instead?

GET / HTTP/1.1
...

What is your $GOOS?  $GOARCH?

linux amd64

Which revision are you using?  (hg identify)

5af6f6656531 tip

Please provide any additional information below.

The problem is clearly in src/pkg/http/request.go here's code:

    fmt.Fprintf(w, "%s %s HTTP/1.1\r\n", valueOrDefault(req.Method, "GET"), uri)

and although function comment explicitly states that request will be HTTP/1.1:

// Write writes an HTTP/1.1 request -- header and body -- in wire format.

i reckon that all request fields should be respected, including Proto*.
@bradfitz
Copy link
Contributor

Comment 1:

It's a bit more complicated than just changing the HTTP/1.1 to HTTP/%d.%d though, as the
go http package only supports chunked encoding.  It has no support for slurping up
bodies ahead of time to measure their length and add HTTP/1.0 Content-Length headers. 
That'd likely be a lot of work.
The easier fix might just be a documentation clarification that requests are always
HTTP/1.1.

@adg
Copy link
Contributor

adg commented Jul 13, 2010

Comment 2:

IIRC it was mentioned in a golang-dev thread that this behaviour breaks something. What
was it?

@adg
Copy link
Contributor

adg commented Jul 21, 2010

Comment 3:

Owner changed to a...@golang.org.

Status changed to Accepted.

@bradfitz
Copy link
Contributor

Comment 4:

Labels changed: added pkg-http.

Owner changed to @bradfitz.

@bradfitz
Copy link
Contributor

Comment 5:

Now that it's possible to send un-chunked requests (by setting Request.ContentLength >
0), I'm closing this with just a documentation update:
http://golang.org/cl/4439062

@bradfitz
Copy link
Contributor

Comment 6:

This issue was closed by revision 8d6a12f.

Status changed to Fixed.

@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