Skip to content

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

@gopherbot

Description

@gopherbot

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*.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions