-
Notifications
You must be signed in to change notification settings - Fork 18k
net/http: Transfer-Encoding header is missing in headers (http.Request) #27061
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Python web server code #!/usr/bin/env python
"""
Very simple HTTP server in python.
Usage::
./dummy-web-server.py [<port>]
Send a GET request::
curl http://localhost
Send a HEAD request::
curl -I http://localhost
Send a POST request::
curl -d "foo=bar&bin=baz" http://localhost
"""
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
import SocketServer
class S(BaseHTTPRequestHandler):
def _set_headers(self):
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
def do_GET(self):
self._set_headers()
self.wfile.write("<html><body><h1>hi!</h1></body></html>")
def do_HEAD(self):
self._set_headers()
def do_PUT(self):
request_path = self.path
print("\n----- Request Start ----->\n")
print(request_path)
request_headers = self.headers
print(request_headers)
print("<----- Request End -----\n")
self.send_response(200)
def run(server_class=HTTPServer, handler_class=S, port=9777):
server_address = ('', port)
httpd = server_class(server_address, handler_class)
print 'Starting httpd...'
httpd.serve_forever()
if __name__ == "__main__":
from sys import argv
if len(argv) == 2:
run(port=int(argv[1]))
else:
run() |
Transfer-Encoding is a hop by hop header. https://tools.ietf.org/html/rfc2616#section-13.5.1 |
/cc @bradfitz |
See the http.Request docs. (on phone, so no link) |
@bradfitz - Do you mean Transfer-Encoding is also included in "certain headers" ? https://golang.org/pkg/net/http/#Request
|
I got
|
Ran into this, but the answer is it gets copied to a separate field on the request/response: https://pkg.go.dev/net/http#Request.TransferEncoding. Pretty sure this can be closed. |
Transfer-Encoding header is missing when http.Request.Header is printed/accessed.
What version of Go are you using (
go version
)?go version go1.10.3 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN="/Users/user/go/bin"
GOCACHE="/Users/sumalepa/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="linux"
GOPATH="/Users/user/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.10.3/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.10.3/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="0"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/76/trlnwqwj0bs5003x850kzpg00000gn/T/go-build494326801=/tmp/go-build -gno-record-gcc-switches"
What did you do?
We have a nginx server that routes the requests to go based http server.
https://play.golang.org/p/EA1vcoiFi_J
What did you expect to see?
We expected to see the header Transfer-Encoding
What did you see instead?
Missing header Transfer-Encoding
Few Details:
Http-Client (User-Agent [Go-http-client/1.1]) -> Nginx -> Http server (Go based server)
Sent a PUT request from client with chunked encoding header to nginx in turn nginx sends the request to http server.
I was able to see the headers in the pcap dumps captured at client, nginx. But on go http server I didn't the header.
But in the go http server output I didn't see the Transfer-Encoding header.
As a part of debug process I replaces go http server with python http server. I was able to see the Transfer-Encoding header on http python server.
The text was updated successfully, but these errors were encountered: