anmonteiro / httpun-ws

Other
28 stars 14 forks source link

How to report an exception while reading a handshake failure response #40

Open aantron opened 2 years ago

aantron commented 2 years ago

The Lwt client type, Websocketaf_lwt*.Client.t is abstract:

https://github.com/anmonteiro/websocketaf/blob/248a2cb0dcffa51996c3ad7643577dce75d67454/lwt/websocketaf_lwt_intf.ml#L51

and not made concrete in either Websocketaf_lwt or Websocketaf_lwt_unix, and there seem to be no accessors for extracting either a Websocketaf.Client_connection.t or Httpaf.Client_connection.t from it. After receiving a `Handshake_failure response,

https://github.com/anmonteiro/websocketaf/blob/248a2cb0dcffa51996c3ad7643577dce75d67454/lib/websocketaf.mli#L184-L186

which is an ordinary situation in case of 3xx redirect, a client written over websocket/af will "want" to treat the response as if it is an HTTP/1 client using http/af. In particular, if it needs to abort body reading with an exception, it will want to call report_exn, which is available on Websocketaf.Client_connection.t:

https://github.com/anmonteiro/websocketaf/blob/248a2cb0dcffa51996c3ad7643577dce75d67454/lib/websocketaf.mli#L219

and a similar function is available o nHttpaf.Client_connection.t. However, it doesn't seem possible to get either Client_connection.t at this point.