[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [meek/master] Explicitly set Content-Length to zero when there is no data to send.
commit 0ea861efe5873b517fbd08c4bc48027e4db16a95
Author: Ivan Markin <twim@xxxxxxxxxx>
Date: Sun Jul 9 19:56:56 2017 +0000
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.
---
meek-client/meek-client.go | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/meek-client/meek-client.go b/meek-client/meek-client.go
index 9a818d0..d378b8b 100644
--- a/meek-client/meek-client.go
+++ b/meek-client/meek-client.go
@@ -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
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits