Golang HTTP POST using HTTP / 1.0

Can I send HTTP requests with HTTP / 1.0 using 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 looks like req.Proto is being ignored. The message is sent using HTTP / 1.1.

+3


source to share


1 answer


Apparently you can't. The field is Request.Proto

ignored when executing the request Client

.

Quoting from the doc 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.

+2


source







All Articles