Alpaca responds with a 200 OK, and Go's ResponseWriter.WriteHeader() will automatically add Transfer-Encoding: chunked to the response header
It then blindly copies data back and forth between the client and the server, but this data is not chunk encoded, and Safari's chunk decoder appears to fail as a result
A server MUST NOT send any Transfer-Encoding or Content-Length header fields in a 2xx (Successful) response to CONNECT. A client MUST ignore any Content-Length or Transfer-Encoding header fields received in a successful response to CONNECT.
It's not clear to me why Safari isn't ignoring the Transfer-Encoding header from Alpaca, but I think it should.
This also needs to be fixed in Alpaca by writing the CONNECT response directly to the connection (using Conn.Write()), rather than using Go's ResponseWriter.
Here's what's going on:
ResponseWriter.WriteHeader()
will automatically addTransfer-Encoding: chunked
to the response headerAccording to https://tools.ietf.org/html/rfc7231#section-4.3.6:
It's not clear to me why Safari isn't ignoring the Transfer-Encoding header from Alpaca, but I think it should.
This also needs to be fixed in Alpaca by writing the CONNECT response directly to the connection (using
Conn.Write()
), rather than using Go'sResponseWriter
.