report exceptions before closing the body #188
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.
In #148 we made sure the close and flush the body so that the receiver
wouldn't potentially be left waiting. This changes the order so that the
error handler is always called first, and then the body eof is sent. In
practice, user code will typically wait for the response handler to be
called, and at that point their only signal that the request is complete
is to wait for the body eof. Likewise, the signal that there was an
error and the request will not complete is the error handler. You can
imagine having some client setup code that looks like this:
By making sure we fire the error handler first, the user can correctly
identify the result of the request and not accidentally mark it as
complete. Fixes #187.