Don't send response chunk for HEAD request #175
Merged
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.
A
StyxProxySpec "should respond to HEAD with bodiless response"
is failing intermittently. The root cause is a combination of slightly incorrect usage of Netty combined with asynchronous behaviour of the e2e tests.The test case fails because Netty
HttpResponseEncoder
leaks (to the network) an empty content chunk whenever Styx responds to a HTTP request. For example:The last
0....
in above log represents the leaked content chunk. The test case fails, specifically, when the leaked chunk arrives at the receiving end (a test HTTP client at StyxProxySpec) before a test client has started decoding the response message.The test pass when the test client had started decoding the HTTP response before the leaked
0...
arrives. In this case the response is decoded correctly and the test case validation completes.The test fails when HTTP response decoding starts after the
0...
had arrived. In this case the0...
is decoded together with the response and treated as a beginning of the next message. This causes a decoding failure due to invalid HTTP version format, and the decoder throws a Netty Channel Exception resulting in a test failure.The
0...
is leaked to the network because Styx had separateHttpResponseEncoder
andHttpRequestDecoder
codecs in the channel pipeline. The separate codecs are unaware of each other and therefore the response encoder cannot know it is responding to a HEAD request.The fix is to use
HttpServerCodec
instead. It is aware of the HEAD response and prevents extra content chunks from being sent.