mirror of
https://github.com/YGGverse/agate.git
synced 2026-04-09 04:55:27 +00:00
Send close_notify before closing connection
This commit is contained in:
parent
33d39cc34b
commit
c563f27b1a
1 changed files with 6 additions and 4 deletions
10
src/main.rs
10
src/main.rs
|
|
@ -102,17 +102,19 @@ fn check_path(s: String) -> Result<String, String> {
|
||||||
|
|
||||||
/// Handle a single client session (request + response).
|
/// Handle a single client session (request + response).
|
||||||
async fn handle_request(stream: TcpStream) -> Result {
|
async fn handle_request(stream: TcpStream) -> Result {
|
||||||
// Perform handshake.
|
|
||||||
static TLS: Lazy<TlsAcceptor> = Lazy::new(|| acceptor().unwrap());
|
|
||||||
let stream = &mut TLS.accept(stream).await?;
|
let stream = &mut TLS.accept(stream).await?;
|
||||||
|
|
||||||
match parse_request(stream).await {
|
match parse_request(stream).await {
|
||||||
Ok(url) => send_response(url, stream).await,
|
Ok(url) => send_response(url, stream).await?,
|
||||||
Err((status, msg)) => send_header(stream, status, &[msg]).await,
|
Err((status, msg)) => send_header(stream, status, &[msg]).await?,
|
||||||
}
|
}
|
||||||
|
stream.shutdown().await?;
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TLS configuration.
|
/// TLS configuration.
|
||||||
|
static TLS: Lazy<TlsAcceptor> = Lazy::new(|| acceptor().unwrap());
|
||||||
|
|
||||||
fn acceptor() -> Result<TlsAcceptor> {
|
fn acceptor() -> Result<TlsAcceptor> {
|
||||||
let cert_file = File::open(&ARGS.cert_file)?;
|
let cert_file = File::open(&ARGS.cert_file)?;
|
||||||
let certs = certs(&mut BufReader::new(cert_file)).or(Err("bad cert"))?;
|
let certs = certs(&mut BufReader::new(cert_file)).or(Err("bad cert"))?;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue