mirror of
https://github.com/YGGverse/agate.git
synced 2026-04-08 20:45:29 +00:00
Minor cleanup in parse_request
This commit is contained in:
parent
a049beb66b
commit
cac7e394be
1 changed files with 3 additions and 4 deletions
|
|
@ -89,14 +89,13 @@ async fn parse_request(stream: &mut TlsStream<TcpStream>) -> Result<Url> {
|
||||||
while !buf.is_empty() {
|
while !buf.is_empty() {
|
||||||
let n = stream.read(buf).await?;
|
let n = stream.read(buf).await?;
|
||||||
len += n;
|
len += n;
|
||||||
if n == 0 || request[..len].ends_with(b"\r\n") {
|
if request[..len].ends_with(b"\r\n") {
|
||||||
break;
|
break;
|
||||||
|
} else if n == 0 {
|
||||||
|
Err("Request ended unexpectedly")?
|
||||||
}
|
}
|
||||||
buf = &mut request[len..];
|
buf = &mut request[len..];
|
||||||
}
|
}
|
||||||
if !request[..len].ends_with(b"\r\n") {
|
|
||||||
Err("Missing CRLF")?
|
|
||||||
}
|
|
||||||
let request = str::from_utf8(&request[..len - 2])?;
|
let request = str::from_utf8(&request[..len - 2])?;
|
||||||
|
|
||||||
let url = if request.starts_with("//") {
|
let url = if request.starts_with("//") {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue