Skip to content
Snippets Groups Projects
Commit 0ea861ef authored by Ivan Markin's avatar Ivan Markin Committed by David Fifield
Browse files

Explicitly set Content-Length to zero when there is no data to send.

Since Go 1.8 http.Transport does not set Content-Length header
if body contains no bytes.
https://golang.org/doc/go1.8#net_http
https://go-review.googlesource.com/c/31445/

However some of domain fronts do inspect Content-Length header
and return 411 error when it is not set. This breaks connection
entierly since these packets do not travel beyond a frontend
to a meek server.

Closes #22865.
parent a26d0998
No related branches found
No related tags found
No related merge requests found
......@@ -116,7 +116,11 @@ type RequestInfo struct {
// Do an HTTP roundtrip using the payload data in buf and the request metadata
// in info.
func roundTripWithHTTP(buf []byte, info *RequestInfo) (*http.Response, error) {
req, err := http.NewRequest("POST", info.URL.String(), bytes.NewReader(buf))
var body io.Reader
if len(buf) > 0 {
body = bytes.NewReader(buf)
}
req, err := http.NewRequest("POST", info.URL.String(), body)
if err != nil {
return nil, err
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment