Don't return error response when clientError is a pipelined HPE_INVALID_METHOD #4471
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes the specific issue in #4363.
This is done by specialcasing
clientError
errors with codeHPE_INVALID_METHOD
that have an active request. Since the active request definitely has a valid method (otherwise it would not have passed through the router), this error originates from request data that is supposed to relate to the next request. As such, it should not respond with an error, but with the normal response. A hook is installed to make the connection close once this has been delivered.Since the existing test suite only exercises this with
err.code === 'HPE_INVALID_METHOD'
, I have added an extra test to exercise it witherr.code === 'HPE_INVALID_CHUNK_SIZE'
to keep the code coverage at 100%.I also made a minor cleanup to
request._finalize()
andrequest. _setResponse()
._finalize()
seems to somewhat assume that any non-Boomthis.response
object is aResponse
, when it can also be aSymbol
.Note that ideally, the current request should add a
connection: close
header, to indicate that it will close the connection.Closes #4363. Closes #4364.