tokio-rs / tls

A collection of Tokio based TLS libraries.
https://tokio.rs
MIT License
253 stars 86 forks source link

add server::AsyncAcceptor with take_io function #144

Closed jacott closed 1 year ago

jacott commented 1 year ago

This is a handle on a server-side connection before configuration is available. This is a replacement for LazyConfigAcceptor which has no way to retrieve the client IO stream after an error.

AsyncAcceptor has a function take_io which can be used take back ownership of the client IO stream.

An example of this is when a client tries to connect to an TLS socket expecting it to be plain text connection. In this case take_io can be used to send a 400 response, "The plain HTTP request was sent to HTTPS port", back to the client.

The reason for a new struct is not break the API of LazyConfigAcceptor.