We have written a service which sends some encoded data as chunked to a proxy service which need Content-Length header to be set so that it can send proper response to end point. Even if I set the Content-Length header still it get stripped as part of the response to the client. Below is the code which set the header
func HTTPSuccessResponse(rw http.ResponseWriter, bufferLen int, media []byte) {
rw.WriteHeader(http.StatusOK)
rw.Header().Set("Content-Type", "opus/ogg; audio/ogg; codec=opus")
length := strconv.Itoa(len(media));
rw.Header().Set("Content-Length", length)
rw.Write(media)
}
Below is the response I get when I try to the request using curl
bash-4.2# curl -v -X GET -k -H -i 'http://127.0.0.1:8090/preview'
* About to connect() to 127.0.0.1 port 8090 (#0)
* Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8090 (#0)
> GET /preview HTTP/1.1
> User-Agent: curl/7.29.0
> Host: 127.0.0.1:8090
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Tue, 14 May 2019 13:08:20 GMT
< Content-Type: text/plain; charset=utf-8
< Transfer-Encoding: chunked
<
I am using Gorrila Mux library for setting up HTTP server. Any thoughts how to make the header as part of the response.