Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions bhttp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,24 @@ readme.workspace = true
default = []
http = ["dep:url"]
stream = ["dep:futures", "dep:pin-project"]
http-compat = ["http", "stream", "dep:http", "dep:futures", "dep:http-body", "dep:futures-core", "dep:bytes", "dep:tokio-util", "tokio-util/compat", "tokio-util/io", "dep:tokio", "dep:async-stream"]

[dependencies]
futures = {version = "0.3", optional = true}
pin-project = {version = "1.1", optional = true}
thiserror = "2"
url = {version = "2", optional = true}
bytes = { version = "1.0", optional = true }
futures-core = { version = "0.3.24", optional = true }
http = { version = "1.0", optional = true }
http-body = { version = "1.0", optional = true }
tokio-util = { version = "0.7.16", optional = true }
tokio = { version = "1.47.1", optional = true, default-features = false }
async-stream = { version = "0.3.6", optional = true }

[dev-dependencies]
hex = "0.4"
http-body-util = "0.1"

[dev-dependencies.sync-async]
path= "../sync-async"
14 changes: 14 additions & 0 deletions bhttp/src/err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ pub enum Error {
ConnectUnsupported,
#[error("a field contained invalid Unicode: {0}")]
CharacterEncoding(#[from] std::string::FromUtf8Error),
#[error("a field contained invalid Unicode: {0}")]
CharacterEncoding2(#[from] std::str::Utf8Error),
#[error("read a response when expecting a request")]
ExpectedRequest,
#[error("read a request when expecting a response")]
Expand Down Expand Up @@ -37,6 +39,18 @@ pub enum Error {
#[error("a URL could not be parsed into components: {0}")]
#[cfg(feature = "http")]
UrlParse(#[from] url::ParseError),
#[error("the status code was not supported {0}")]
#[cfg(feature = "http-compat")]
UnsportedStatusCode(u16),
#[error("got an unknown HTTP body frame type, only data frame and trailer frame are supported")]
#[cfg(feature = "http-compat")]
UnknownHttpBodyFrameType,
#[error("http error")]
#[cfg(feature = "http-compat")]
HttpError(#[from] http::Error),
#[error("http header value contains invalid bytes")]
#[cfg(feature = "http-compat")]
HttpHeaderValueNotString(#[from] http::header::ToStrError),
}

pub type Res<T> = Result<T, Error>;
Loading
Loading