ninenines / gun

HTTP/1.1, HTTP/2, Websocket client (and more) for Erlang/OTP.
ISC License
891 stars 232 forks source link

Add state (current state name) info field in gun:info/1 #293

Open zuiderkwast opened 2 years ago

zuiderkwast commented 2 years ago

It's useful to be able to check the HTTP connection status (connected, closing, not connected, etc.). The current gen_statem state name provides exactly this info. This commit adds it to gun:info/1 under the key state.

zuiderkwast commented 9 months ago

This one is waiting as well.

If you don't accept exposing the internal gen_statem states, then how about a variant with fewer states (e.g. connecting | connected | closing) instead of the full not_connected | domain_lookup | connecting | initial_tls_handshake | tls_handshake | connected | closing?

Or if you don't accept it at all, it's better to know that and close it.

essen commented 9 months ago

Probably best to document it as atom() so they can be changed without it being a breaking change if necessary.

essen commented 9 months ago

One final change, sorry I didn't think about this earlier. I think we should name the field state_name instead of state to avoid any unnecessary confusion with the process state.