Skip to content

Commit

Permalink
check for transferEncoding as well
Browse files Browse the repository at this point in the history
  • Loading branch information
gurgunday committed Apr 22, 2024
1 parent 44dc0a5 commit 97ede71
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/handleRequest.js
Expand Up @@ -29,21 +29,20 @@ function handleRequest (err, request, reply) {
if (bodyMethods.has(method)) {
const contentType = headers['content-type']
const contentLength = headers['content-length']
const transferEncoding = headers['transfer-encoding']

if (contentType === undefined) {
const transferEncoding = headers['transfer-encoding']

if (
transferEncoding === undefined &&
(contentLength === undefined || contentLength === '0')
(contentLength === undefined || contentLength === '0') &&
transferEncoding === undefined
) {
// Request has no body to parse
handler(request, reply)
} else {
context.contentTypeParser.run('', handler, request, reply)
}
} else {
if (contentLength === undefined && method === 'OPTIONS') {
if (contentLength === undefined && transferEncoding === undefined && method === 'OPTIONS') {
// OPTIONS can have a Content-Type header without a body
handler(request, reply)
return
Expand Down

0 comments on commit 97ede71

Please sign in to comment.