TritonDataCenter / node-manta

Node.js SDK for Manta
75 stars 54 forks source link

content-length and transfer-encoding chunked must not be used together #294

Closed kusor closed 7 years ago

kusor commented 7 years ago

Usage of the content-length header with node-manta client, (any version after 3.x) results into muskie server terminating the HTTP connection with a socket hang up error:

HTTP 47513: SERVER new http connection
HTTP 47513: SERVER socketOnParserExecute NaN
HTTP 47513: parse error
HTTP 47513: server socket close

The reason for this failure is the presence on the same message of both HTTP headers, which is explicitly disallowed by the HTTP 1.1 spec (see https://tools.ietf.org/html/rfc2616#section-4.4).

The fix introduced for MANTA-2937 adds the Transfer-Encoding: chunked header despite or not of Content-Length header being present on MantaClient.chattr options, which results into the aforementioned issue, affecting muskie tests case https://github.com/joyent/manta-muskie/blob/master/test/obj.test.js#L383-L398

Suggested fix is to just append the Transfer-Encoding: chunked header only when Content-Length is not already present