hapijs / hapijs/h2o2

DELETE with content-length 0 produces a technically incorrect payload

Open
#140 3 comments 3 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
164
Forks
61
PR merge metrics
No merged PRs in 30d

Description

### Runtime

node.js

### Runtime version

v20.11.0

### Module version

10.0.4

### Last module version without issue

_No response_

### Used with

hapi

### Any other relevant information

_No response_

### What are you trying to achieve or the steps to reproduce?

We are using h2o2 to proxy requests. We have found that sending a DELETE request with a content-length of 0 has an unexpected result:

* We get a 0 length Buffer as the payload
* h2o2 then concludes that since there's no transfer-encoding header in the originating request, (no encoding), there IS a payload, and this is a DELETe method that it should [add a transfer-encoding: chunked header](https://github.com/hapijs/h2o2/blob/651d36189eea61fec97f7849573d57f0abbae03f/lib/index.js#L160-L162)
* Later on, the overall hapi system concludes (it seems) that since there IS a Buffer instance (even if 0) it will add a content-length header

### What was the result you got?

The result is that the request that is sent on has both a transfer-encoding and a content-length header. Evidently, this is technically incorrect. We have two other servers in our systems which do not like this header combination and reject the request. (other servers don't seem to care)

### What result did you expect?

Probably that if there is no content, that we do not set a transfer-encoding header?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.