Skip to content

Commit b2477f7

Browse files
remove thiserror dep
1 parent e83617c commit b2477f7

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ url = "2.1.0"
1616
httparse = "1.3.3"
1717
async-std = { version = "1.4.0", features = ["unstable"] }
1818
http-types = { path = '../http-types' }
19-
thiserror = "1.0.9"
2019
pin-project-lite = "0.1.1"
2120
byte-pool = "0.2.1"
2221
lazy_static = "1.4.0"

src/server.rs

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//! Process HTTP connections on the server.
22
3+
use std::error::Error;
4+
use std::fmt;
5+
use std::pin::Pin;
6+
use std::str::FromStr;
7+
use std::time::Duration;
8+
39
use async_std::future::{timeout, Future, TimeoutError};
410
use async_std::io::{self, BufReader};
511
use async_std::io::{Read, Write};
@@ -8,23 +14,37 @@ use async_std::task::{Context, Poll};
814
use futures_core::ready;
915
use http_types::headers::{HeaderName, HeaderValue, CONTENT_LENGTH, TRANSFER_ENCODING};
1016
use http_types::{Body, Method, Request, Response};
11-
use std::str::FromStr;
12-
use std::time::Duration;
13-
use thiserror::Error;
14-
15-
use std::pin::Pin;
1617

1718
use crate::chunked::ChunkedDecoder;
1819
use crate::date::fmt_http_date;
1920
use crate::{Exception, MAX_HEADERS};
2021

2122
/// Errors when handling incoming requests.
22-
#[derive(Debug, Error)]
23+
#[derive(Debug)]
2324
pub enum HttpError {
24-
#[error("unexpected content-length header")]
2525
UnexpectedContentLengthHeader,
2626
}
2727

28+
impl fmt::Display for HttpError {
29+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
30+
match self {
31+
HttpError::UnexpectedContentLengthHeader => write!(f, "{}", self.description()),
32+
}
33+
}
34+
}
35+
36+
impl Error for HttpError {
37+
fn description(&self) -> &str {
38+
match self {
39+
HttpError::UnexpectedContentLengthHeader => "unexpected content-length header",
40+
}
41+
}
42+
43+
fn cause(&self) -> Option<&dyn Error> {
44+
None
45+
}
46+
}
47+
2848
/// Parse an incoming HTTP connection.
2949
///
3050
/// Supports `KeepAlive` requests by default.

0 commit comments

Comments
 (0)