Skip to content

Conversation

@xeioex
Copy link
Contributor

@xeioex xeioex commented Jun 17, 2025

body value length takes precedence over Content-Length from header list.

https://fetch.spec.whatwg.org/#http-network-or-cache-fetch

Let contentLength be httpRequest’s body’s length, if httpRequest’s body

is non-null; otherwise null.

Let contentLengthHeaderValue be null.

If httpRequest’s body is null and httpRequest’s method is `POST` or

PUT, then set contentLengthHeaderValue to 0.

If contentLength is non-null, then set contentLengthHeaderValue to

contentLength, serialized and isomorphic encoded.

If contentLengthHeaderValue is non-null, then append (`Content-Length`,

contentLengthHeaderValue) to httpRequest’s header list.

This fixes #930 issue in Github.

body value length takes precedence over Content-Length from header list.

    https://fetch.spec.whatwg.org/#http-network-or-cache-fetch

    Let contentLength be httpRequest’s body’s length, if httpRequest’s body
is non-null; otherwise null.

    Let contentLengthHeaderValue be null.

    If httpRequest’s body is null and httpRequest’s method is `POST` or
`PUT`, then set contentLengthHeaderValue to `0`.

    If contentLength is non-null, then set contentLengthHeaderValue to
contentLength, serialized and isomorphic encoded.

    If contentLengthHeaderValue is non-null, then append (`Content-Length`,
contentLengthHeaderValue) to httpRequest’s header list.

This fixes nginx#930 issue in Github.
Copy link
Contributor

@VadimZhestikov VadimZhestikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@xeioex xeioex merged commit 34b8051 into nginx:master Jun 18, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Strange error 400 from ngx.fetch with body

2 participants