Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
report exceptions before closing the body
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: ```ocaml let result = Ivar.create () in let on_eof () = Ivar.fill_if_empty result (Ok ()) in let error_handler e = Ivar.fill_if_empty result (Error e) in (* ... *) ``` 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.
- Loading branch information