This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
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 branch adds server- and client-side support for HTTP/1.1 Expect/continue.
This is important because some clients (e.g., Curl) will send Expect/Continue on requests with bodies, and by default will pause until either a) they see a 100 Continue response, or b) they time out (1-3 secs, IME). Since node doesn't handle Expect/continue, it introduces an unnecessary delay.
On the server side, it creates a new event, 'check_continue' that is emitted when a request contains 'Expect: 100-continue'.
The event is passed request and response objects, just like the 'request' event. If the server wants the request to continue, it calls response.sendContinue(); if not, it sends a final status code. Note that 'request' is not fired if 'check_continue' is; see the test case for an example.
If the event is not handled, node will automagically generate the 100 Continue when appropriate. This is IMO the most reasonable default behaviour, while still allowing full control over the feature.
On the client side, it creates a new 'continue' event that's fired if a 100 Continue is received.
This probably needs a bit more testing around the corner cases to make sure it always does the right thing; I'll try to do so and report back. Just figured it would be good to get some review and others' experience in the meantime.