appcues / mojito

An easy-to-use Elixir HTTP client, built on the low-level Mint library.
https://hexdocs.pm/mojito/Mojito.html
MIT License
349 stars 34 forks source link

Don't return timed-out response on the next request #33

Closed gamache closed 5 years ago

gamache commented 5 years ago

This PR adds a unique reference to every :mojito_response message sent, so that the receiver can match on the reference to ensure the response is associated with the current request and not a request that timed out in the past. (EDIT: this is handled internally and does not require end user changes.)

It was also a convenient time to do some refactoring to use %Mojito.Request{} structs more consistently across internal functions, so I did that too. The external surface of Mojito did not change.

Fixes #32.

gamache commented 5 years ago

Yeah, it's a bit confusing between the Mint-supplied request_ref (used by Mojito.ConnServer to disentangle multiplexed requests) and the Mojito response_ref (used by Mojito.Pool.Single to identify the proper response for the current request). Similar concepts, similar names.

andyleclair commented 5 years ago

Still, don't let my confusion stall this bugfix