plithner
plithner

Reputation: 325

Golang HTTP POST using HTTP/1.0

Is it possible to send HTTP requests using HTTP/1.0 with golang?

I tried the following:

req, _ := http.NewRequest("POST", url, buffer)
req.Proto = "HTTP/1.0"
client := &http.Client{}
resp, err = client.Do(req)

But it seems req.Proto is ignored. The message is sent out using HTTP/1.1.

Upvotes: 4

Views: 4759

Answers (1)

icza
icza

Reputation: 417592

Apparently you can't. The Request.Proto field is ignored when making the request by the Client.

Quoting from the doc of http.Request:

// The protocol version for incoming requests.
// Client requests always use HTTP/1.1.
Proto      string // "HTTP/1.0"

Client requests always use HTTP/1.1.

Upvotes: 4

Related Questions