mirror of
https://github.com/actix/actix-web.git
synced 2024-11-27 20:11:15 +00:00
build(deps): update derive_more to v1.0 (#3453)
* build(deps): update derive_more to v1.0 * refactor: use from derive module --------- Co-authored-by: Rob Ede <robjtede@icloud.com>
This commit is contained in:
parent
78ac5cf482
commit
d6bdfac1b9
40 changed files with 204 additions and 194 deletions
|
@ -19,7 +19,7 @@ homepage = "https://actix.rs"
|
||||||
repository = "https://github.com/actix/actix-web"
|
repository = "https://github.com/actix/actix-web"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.72"
|
rust-version = "1.75"
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
# Disabling debug info speeds up builds a bunch and we don't rely on it for debugging that much.
|
# Disabling debug info speeds up builds a bunch and we don't rely on it for debugging that much.
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
- Minimum supported Rust version (MSRV) is now 1.75.
|
||||||
|
|
||||||
## 0.6.6
|
## 0.6.6
|
||||||
|
|
||||||
- Update `tokio-uring` dependency to `0.4`.
|
- Update `tokio-uring` dependency to `0.4`.
|
||||||
|
|
|
@ -33,7 +33,7 @@ actix-web = { version = "4", default-features = false }
|
||||||
|
|
||||||
bitflags = "2"
|
bitflags = "2"
|
||||||
bytes = "1"
|
bytes = "1"
|
||||||
derive_more = "0.99.5"
|
derive_more = { version = "1", features = ["display", "error", "from"] }
|
||||||
futures-core = { version = "0.3.17", default-features = false, features = ["alloc"] }
|
futures-core = { version = "0.3.17", default-features = false, features = ["alloc"] }
|
||||||
http-range = "0.1.4"
|
http-range = "0.1.4"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
use actix_web::{http::StatusCode, ResponseError};
|
use actix_web::{http::StatusCode, ResponseError};
|
||||||
use derive_more::Display;
|
use derive_more::derive::Display;
|
||||||
|
|
||||||
/// Errors which can occur when serving static files.
|
/// Errors which can occur when serving static files.
|
||||||
#[derive(Debug, PartialEq, Eq, Display)]
|
#[derive(Debug, PartialEq, Eq, Display)]
|
||||||
pub enum FilesError {
|
pub enum FilesError {
|
||||||
/// Path is not a directory.
|
/// Path is not a directory.
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[display(fmt = "path is not a directory. Unable to serve static files")]
|
#[display("path is not a directory. Unable to serve static files")]
|
||||||
IsNotDirectory,
|
IsNotDirectory,
|
||||||
|
|
||||||
/// Cannot render directory.
|
/// Cannot render directory.
|
||||||
#[display(fmt = "unable to render directory without index file")]
|
#[display("unable to render directory without index file")]
|
||||||
IsDirectory,
|
IsDirectory,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,19 +25,19 @@ impl ResponseError for FilesError {
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum UriSegmentError {
|
pub enum UriSegmentError {
|
||||||
/// Segment started with the wrapped invalid character.
|
/// Segment started with the wrapped invalid character.
|
||||||
#[display(fmt = "segment started with invalid character: ('{_0}')")]
|
#[display("segment started with invalid character: ('{_0}')")]
|
||||||
BadStart(char),
|
BadStart(char),
|
||||||
|
|
||||||
/// Segment contained the wrapped invalid character.
|
/// Segment contained the wrapped invalid character.
|
||||||
#[display(fmt = "segment contained invalid character ('{_0}')")]
|
#[display("segment contained invalid character ('{_0}')")]
|
||||||
BadChar(char),
|
BadChar(char),
|
||||||
|
|
||||||
/// Segment ended with the wrapped invalid character.
|
/// Segment ended with the wrapped invalid character.
|
||||||
#[display(fmt = "segment ended with invalid character: ('{_0}')")]
|
#[display("segment ended with invalid character: ('{_0}')")]
|
||||||
BadEnd(char),
|
BadEnd(char),
|
||||||
|
|
||||||
/// Path is not a valid UTF-8 string after percent-decoding.
|
/// Path is not a valid UTF-8 string after percent-decoding.
|
||||||
#[display(fmt = "path is not a valid UTF-8 string after percent-decoding")]
|
#[display("path is not a valid UTF-8 string after percent-decoding")]
|
||||||
NotValidUtf8,
|
NotValidUtf8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ use actix_web::{
|
||||||
Error, HttpMessage, HttpRequest, HttpResponse, Responder,
|
Error, HttpMessage, HttpRequest, HttpResponse, Responder,
|
||||||
};
|
};
|
||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
use derive_more::{Deref, DerefMut};
|
use derive_more::derive::{Deref, DerefMut};
|
||||||
use futures_core::future::LocalBoxFuture;
|
use futures_core::future::LocalBoxFuture;
|
||||||
use mime::Mime;
|
use mime::Mime;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use derive_more::Error;
|
use derive_more::derive::Error;
|
||||||
|
|
||||||
/// Copy of `http_range::HttpRangeParseError`.
|
/// Copy of `http_range::HttpRangeParseError`.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
- Minimum supported Rust version (MSRV) is now 1.75.
|
||||||
|
|
||||||
## 3.9.0
|
## 3.9.0
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -110,7 +110,7 @@ ahash = "0.8"
|
||||||
bitflags = "2"
|
bitflags = "2"
|
||||||
bytes = "1"
|
bytes = "1"
|
||||||
bytestring = "1"
|
bytestring = "1"
|
||||||
derive_more = "0.99.5"
|
derive_more = { version = "1", features = ["as_ref", "deref", "deref_mut", "display", "error", "from"] }
|
||||||
encoding_rs = "0.8"
|
encoding_rs = "0.8"
|
||||||
futures-core = { version = "0.3.17", default-features = false, features = ["alloc"] }
|
futures-core = { version = "0.3.17", default-features = false, features = ["alloc"] }
|
||||||
http = "0.2.7"
|
http = "0.2.7"
|
||||||
|
@ -160,7 +160,7 @@ rcgen = "0.13"
|
||||||
regex = "1.3"
|
regex = "1.3"
|
||||||
rustversion = "1"
|
rustversion = "1"
|
||||||
rustls-pemfile = "2"
|
rustls-pemfile = "2"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
static_assertions = "1"
|
static_assertions = "1"
|
||||||
tls-openssl = { package = "openssl", version = "0.10.55" }
|
tls-openssl = { package = "openssl", version = "0.10.55" }
|
||||||
|
|
|
@ -75,7 +75,7 @@ mod tests {
|
||||||
time::{sleep, Sleep},
|
time::{sleep, Sleep},
|
||||||
};
|
};
|
||||||
use actix_utils::future::poll_fn;
|
use actix_utils::future::poll_fn;
|
||||||
use derive_more::{Display, Error};
|
use derive_more::derive::{Display, Error};
|
||||||
use futures_core::ready;
|
use futures_core::ready;
|
||||||
use futures_util::{stream, FutureExt as _};
|
use futures_util::{stream, FutureExt as _};
|
||||||
use pin_project_lite::pin_project;
|
use pin_project_lite::pin_project;
|
||||||
|
@ -131,7 +131,7 @@ mod tests {
|
||||||
assert_eq!(to_bytes(body).await.ok(), Some(Bytes::from("12")));
|
assert_eq!(to_bytes(body).await.ok(), Some(Bytes::from("12")));
|
||||||
}
|
}
|
||||||
#[derive(Debug, Display, Error)]
|
#[derive(Debug, Display, Error)]
|
||||||
#[display(fmt = "stream error")]
|
#[display("stream error")]
|
||||||
struct StreamErr;
|
struct StreamErr;
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::task::Poll;
|
||||||
use actix_rt::pin;
|
use actix_rt::pin;
|
||||||
use actix_utils::future::poll_fn;
|
use actix_utils::future::poll_fn;
|
||||||
use bytes::{Bytes, BytesMut};
|
use bytes::{Bytes, BytesMut};
|
||||||
use derive_more::{Display, Error};
|
use derive_more::derive::{Display, Error};
|
||||||
use futures_core::ready;
|
use futures_core::ready;
|
||||||
|
|
||||||
use super::{BodySize, MessageBody};
|
use super::{BodySize, MessageBody};
|
||||||
|
@ -38,7 +38,7 @@ pub async fn to_bytes<B: MessageBody>(body: B) -> Result<Bytes, B::Error> {
|
||||||
|
|
||||||
/// Error type returned from [`to_bytes_limited`] when body produced exceeds limit.
|
/// Error type returned from [`to_bytes_limited`] when body produced exceeds limit.
|
||||||
#[derive(Debug, Display, Error)]
|
#[derive(Debug, Display, Error)]
|
||||||
#[display(fmt = "limit exceeded while collecting body bytes")]
|
#[display("limit exceeded while collecting body bytes")]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub struct BodyLimitExceeded;
|
pub struct BodyLimitExceeded;
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ use std::{
|
||||||
|
|
||||||
use actix_rt::task::{spawn_blocking, JoinHandle};
|
use actix_rt::task::{spawn_blocking, JoinHandle};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use derive_more::Display;
|
use derive_more::derive::Display;
|
||||||
#[cfg(feature = "compress-gzip")]
|
#[cfg(feature = "compress-gzip")]
|
||||||
use flate2::write::{GzEncoder, ZlibEncoder};
|
use flate2::write::{GzEncoder, ZlibEncoder};
|
||||||
use futures_core::ready;
|
use futures_core::ready;
|
||||||
|
@ -415,11 +415,11 @@ fn new_brotli_compressor() -> Box<brotli::CompressorWriter<Writer>> {
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum EncoderError {
|
pub enum EncoderError {
|
||||||
/// Wrapped body stream error.
|
/// Wrapped body stream error.
|
||||||
#[display(fmt = "body")]
|
#[display("body")]
|
||||||
Body(Box<dyn StdError>),
|
Body(Box<dyn StdError>),
|
||||||
|
|
||||||
/// Generic I/O error.
|
/// Generic I/O error.
|
||||||
#[display(fmt = "io")]
|
#[display("io")]
|
||||||
Io(io::Error),
|
Io(io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use std::{error::Error as StdError, fmt, io, str::Utf8Error, string::FromUtf8Error};
|
use std::{error::Error as StdError, fmt, io, str::Utf8Error, string::FromUtf8Error};
|
||||||
|
|
||||||
use derive_more::{Display, Error, From};
|
use derive_more::derive::{Display, Error, From};
|
||||||
pub use http::{status::InvalidStatusCode, Error as HttpError};
|
pub use http::{status::InvalidStatusCode, Error as HttpError};
|
||||||
use http::{uri::InvalidUri, StatusCode};
|
use http::{uri::InvalidUri, StatusCode};
|
||||||
|
|
||||||
|
@ -80,28 +80,28 @@ impl From<Error> for Response<BoxBody> {
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Display)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Display)]
|
||||||
pub(crate) enum Kind {
|
pub(crate) enum Kind {
|
||||||
#[display(fmt = "error processing HTTP")]
|
#[display("error processing HTTP")]
|
||||||
Http,
|
Http,
|
||||||
|
|
||||||
#[display(fmt = "error parsing HTTP message")]
|
#[display("error parsing HTTP message")]
|
||||||
Parse,
|
Parse,
|
||||||
|
|
||||||
#[display(fmt = "request payload read error")]
|
#[display("request payload read error")]
|
||||||
Payload,
|
Payload,
|
||||||
|
|
||||||
#[display(fmt = "response body write error")]
|
#[display("response body write error")]
|
||||||
Body,
|
Body,
|
||||||
|
|
||||||
#[display(fmt = "send response error")]
|
#[display("send response error")]
|
||||||
SendResponse,
|
SendResponse,
|
||||||
|
|
||||||
#[display(fmt = "error in WebSocket process")]
|
#[display("error in WebSocket process")]
|
||||||
Ws,
|
Ws,
|
||||||
|
|
||||||
#[display(fmt = "connection error")]
|
#[display("connection error")]
|
||||||
Io,
|
Io,
|
||||||
|
|
||||||
#[display(fmt = "encoder error")]
|
#[display("encoder error")]
|
||||||
Encoder,
|
Encoder,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,44 +160,44 @@ impl From<crate::ws::ProtocolError> for Error {
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum ParseError {
|
pub enum ParseError {
|
||||||
/// An invalid `Method`, such as `GE.T`.
|
/// An invalid `Method`, such as `GE.T`.
|
||||||
#[display(fmt = "invalid method specified")]
|
#[display("invalid method specified")]
|
||||||
Method,
|
Method,
|
||||||
|
|
||||||
/// An invalid `Uri`, such as `exam ple.domain`.
|
/// An invalid `Uri`, such as `exam ple.domain`.
|
||||||
#[display(fmt = "URI error: {}", _0)]
|
#[display("URI error: {}", _0)]
|
||||||
Uri(InvalidUri),
|
Uri(InvalidUri),
|
||||||
|
|
||||||
/// An invalid `HttpVersion`, such as `HTP/1.1`
|
/// An invalid `HttpVersion`, such as `HTP/1.1`
|
||||||
#[display(fmt = "invalid HTTP version specified")]
|
#[display("invalid HTTP version specified")]
|
||||||
Version,
|
Version,
|
||||||
|
|
||||||
/// An invalid `Header`.
|
/// An invalid `Header`.
|
||||||
#[display(fmt = "invalid Header provided")]
|
#[display("invalid Header provided")]
|
||||||
Header,
|
Header,
|
||||||
|
|
||||||
/// A message head is too large to be reasonable.
|
/// A message head is too large to be reasonable.
|
||||||
#[display(fmt = "message head is too large")]
|
#[display("message head is too large")]
|
||||||
TooLarge,
|
TooLarge,
|
||||||
|
|
||||||
/// A message reached EOF, but is not complete.
|
/// A message reached EOF, but is not complete.
|
||||||
#[display(fmt = "message is incomplete")]
|
#[display("message is incomplete")]
|
||||||
Incomplete,
|
Incomplete,
|
||||||
|
|
||||||
/// An invalid `Status`, such as `1337 ELITE`.
|
/// An invalid `Status`, such as `1337 ELITE`.
|
||||||
#[display(fmt = "invalid status provided")]
|
#[display("invalid status provided")]
|
||||||
Status,
|
Status,
|
||||||
|
|
||||||
/// A timeout occurred waiting for an IO event.
|
/// A timeout occurred waiting for an IO event.
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[display(fmt = "timeout")]
|
#[display("timeout")]
|
||||||
Timeout,
|
Timeout,
|
||||||
|
|
||||||
/// An I/O error that occurred while trying to read or write to a network stream.
|
/// An I/O error that occurred while trying to read or write to a network stream.
|
||||||
#[display(fmt = "I/O error: {}", _0)]
|
#[display("I/O error: {}", _0)]
|
||||||
Io(io::Error),
|
Io(io::Error),
|
||||||
|
|
||||||
/// Parsing a field as string failed.
|
/// Parsing a field as string failed.
|
||||||
#[display(fmt = "UTF-8 error: {}", _0)]
|
#[display("UTF-8 error: {}", _0)]
|
||||||
Utf8(Utf8Error),
|
Utf8(Utf8Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,28 +256,28 @@ impl From<ParseError> for Response<BoxBody> {
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum PayloadError {
|
pub enum PayloadError {
|
||||||
/// A payload reached EOF, but is not complete.
|
/// A payload reached EOF, but is not complete.
|
||||||
#[display(fmt = "payload reached EOF before completing: {:?}", _0)]
|
#[display("payload reached EOF before completing: {:?}", _0)]
|
||||||
Incomplete(Option<io::Error>),
|
Incomplete(Option<io::Error>),
|
||||||
|
|
||||||
/// Content encoding stream corruption.
|
/// Content encoding stream corruption.
|
||||||
#[display(fmt = "can not decode content-encoding")]
|
#[display("can not decode content-encoding")]
|
||||||
EncodingCorrupted,
|
EncodingCorrupted,
|
||||||
|
|
||||||
/// Payload reached size limit.
|
/// Payload reached size limit.
|
||||||
#[display(fmt = "payload reached size limit")]
|
#[display("payload reached size limit")]
|
||||||
Overflow,
|
Overflow,
|
||||||
|
|
||||||
/// Payload length is unknown.
|
/// Payload length is unknown.
|
||||||
#[display(fmt = "payload length is unknown")]
|
#[display("payload length is unknown")]
|
||||||
UnknownLength,
|
UnknownLength,
|
||||||
|
|
||||||
/// HTTP/2 payload error.
|
/// HTTP/2 payload error.
|
||||||
#[cfg(feature = "http2")]
|
#[cfg(feature = "http2")]
|
||||||
#[display(fmt = "{}", _0)]
|
#[display("{}", _0)]
|
||||||
Http2Payload(::h2::Error),
|
Http2Payload(::h2::Error),
|
||||||
|
|
||||||
/// Generic I/O error.
|
/// Generic I/O error.
|
||||||
#[display(fmt = "{}", _0)]
|
#[display("{}", _0)]
|
||||||
Io(io::Error),
|
Io(io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,44 +326,44 @@ impl From<PayloadError> for Error {
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum DispatchError {
|
pub enum DispatchError {
|
||||||
/// Service error.
|
/// Service error.
|
||||||
#[display(fmt = "service error")]
|
#[display("service error")]
|
||||||
Service(Response<BoxBody>),
|
Service(Response<BoxBody>),
|
||||||
|
|
||||||
/// Body streaming error.
|
/// Body streaming error.
|
||||||
#[display(fmt = "body error: {}", _0)]
|
#[display("body error: {}", _0)]
|
||||||
Body(Box<dyn StdError>),
|
Body(Box<dyn StdError>),
|
||||||
|
|
||||||
/// Upgrade service error.
|
/// Upgrade service error.
|
||||||
#[display(fmt = "upgrade error")]
|
#[display("upgrade error")]
|
||||||
Upgrade,
|
Upgrade,
|
||||||
|
|
||||||
/// An `io::Error` that occurred while trying to read or write to a network stream.
|
/// An `io::Error` that occurred while trying to read or write to a network stream.
|
||||||
#[display(fmt = "I/O error: {}", _0)]
|
#[display("I/O error: {}", _0)]
|
||||||
Io(io::Error),
|
Io(io::Error),
|
||||||
|
|
||||||
/// Request parse error.
|
/// Request parse error.
|
||||||
#[display(fmt = "request parse error: {}", _0)]
|
#[display("request parse error: {}", _0)]
|
||||||
Parse(ParseError),
|
Parse(ParseError),
|
||||||
|
|
||||||
/// HTTP/2 error.
|
/// HTTP/2 error.
|
||||||
#[display(fmt = "{}", _0)]
|
#[display("{}", _0)]
|
||||||
#[cfg(feature = "http2")]
|
#[cfg(feature = "http2")]
|
||||||
H2(h2::Error),
|
H2(h2::Error),
|
||||||
|
|
||||||
/// The first request did not complete within the specified timeout.
|
/// The first request did not complete within the specified timeout.
|
||||||
#[display(fmt = "request did not complete within the specified timeout")]
|
#[display("request did not complete within the specified timeout")]
|
||||||
SlowRequestTimeout,
|
SlowRequestTimeout,
|
||||||
|
|
||||||
/// Disconnect timeout. Makes sense for TLS streams.
|
/// Disconnect timeout. Makes sense for TLS streams.
|
||||||
#[display(fmt = "connection shutdown timeout")]
|
#[display("connection shutdown timeout")]
|
||||||
DisconnectTimeout,
|
DisconnectTimeout,
|
||||||
|
|
||||||
/// Handler dropped payload before reading EOF.
|
/// Handler dropped payload before reading EOF.
|
||||||
#[display(fmt = "handler dropped payload before reading EOF")]
|
#[display("handler dropped payload before reading EOF")]
|
||||||
HandlerDroppedPayload,
|
HandlerDroppedPayload,
|
||||||
|
|
||||||
/// Internal error.
|
/// Internal error.
|
||||||
#[display(fmt = "internal error")]
|
#[display("internal error")]
|
||||||
InternalError,
|
InternalError,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,11 +389,11 @@ impl StdError for DispatchError {
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum ContentTypeError {
|
pub enum ContentTypeError {
|
||||||
/// Can not parse content type.
|
/// Can not parse content type.
|
||||||
#[display(fmt = "could not parse content type")]
|
#[display("could not parse content type")]
|
||||||
ParseError,
|
ParseError,
|
||||||
|
|
||||||
/// Unknown content encoding.
|
/// Unknown content encoding.
|
||||||
#[display(fmt = "unknown content encoding")]
|
#[display("unknown content encoding")]
|
||||||
UnknownEncoding,
|
UnknownEncoding,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use derive_more::{Display, Error};
|
use derive_more::derive::{Display, Error};
|
||||||
use http::header::InvalidHeaderValue;
|
use http::header::InvalidHeaderValue;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -11,7 +11,7 @@ use crate::{
|
||||||
|
|
||||||
/// Error returned when a content encoding is unknown.
|
/// Error returned when a content encoding is unknown.
|
||||||
#[derive(Debug, Display, Error)]
|
#[derive(Debug, Display, Error)]
|
||||||
#[display(fmt = "unsupported content encoding")]
|
#[display("unsupported content encoding")]
|
||||||
pub struct ContentEncodingParseError;
|
pub struct ContentEncodingParseError;
|
||||||
|
|
||||||
/// Represents a supported content encoding.
|
/// Represents a supported content encoding.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use derive_more::{Display, Error};
|
use derive_more::derive::{Display, Error};
|
||||||
|
|
||||||
const MAX_QUALITY_INT: u16 = 1000;
|
const MAX_QUALITY_INT: u16 = 1000;
|
||||||
const MAX_QUALITY_FLOAT: f32 = 1.0;
|
const MAX_QUALITY_FLOAT: f32 = 1.0;
|
||||||
|
@ -125,7 +125,7 @@ pub fn itoa_fmt<W: fmt::Write, V: itoa::Integer>(mut wr: W, value: V) -> fmt::Re
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Display, Error)]
|
#[derive(Debug, Clone, Display, Error)]
|
||||||
#[display(fmt = "quality out of bounds")]
|
#[display("quality out of bounds")]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub struct QualityOutOfBounds;
|
pub struct QualityOutOfBounds;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
use derive_more::{Display, Error, From};
|
use derive_more::derive::{Display, Error, From};
|
||||||
use http::{header, Method, StatusCode};
|
use http::{header, Method, StatusCode};
|
||||||
|
|
||||||
use crate::{body::BoxBody, header::HeaderValue, RequestHead, Response, ResponseBuilder};
|
use crate::{body::BoxBody, header::HeaderValue, RequestHead, Response, ResponseBuilder};
|
||||||
|
@ -27,43 +27,43 @@ pub use self::{
|
||||||
#[derive(Debug, Display, Error, From)]
|
#[derive(Debug, Display, Error, From)]
|
||||||
pub enum ProtocolError {
|
pub enum ProtocolError {
|
||||||
/// Received an unmasked frame from client.
|
/// Received an unmasked frame from client.
|
||||||
#[display(fmt = "received an unmasked frame from client")]
|
#[display("received an unmasked frame from client")]
|
||||||
UnmaskedFrame,
|
UnmaskedFrame,
|
||||||
|
|
||||||
/// Received a masked frame from server.
|
/// Received a masked frame from server.
|
||||||
#[display(fmt = "received a masked frame from server")]
|
#[display("received a masked frame from server")]
|
||||||
MaskedFrame,
|
MaskedFrame,
|
||||||
|
|
||||||
/// Encountered invalid opcode.
|
/// Encountered invalid opcode.
|
||||||
#[display(fmt = "invalid opcode ({})", _0)]
|
#[display("invalid opcode ({})", _0)]
|
||||||
InvalidOpcode(#[error(not(source))] u8),
|
InvalidOpcode(#[error(not(source))] u8),
|
||||||
|
|
||||||
/// Invalid control frame length
|
/// Invalid control frame length
|
||||||
#[display(fmt = "invalid control frame length ({})", _0)]
|
#[display("invalid control frame length ({})", _0)]
|
||||||
InvalidLength(#[error(not(source))] usize),
|
InvalidLength(#[error(not(source))] usize),
|
||||||
|
|
||||||
/// Bad opcode.
|
/// Bad opcode.
|
||||||
#[display(fmt = "bad opcode")]
|
#[display("bad opcode")]
|
||||||
BadOpCode,
|
BadOpCode,
|
||||||
|
|
||||||
/// A payload reached size limit.
|
/// A payload reached size limit.
|
||||||
#[display(fmt = "payload reached size limit")]
|
#[display("payload reached size limit")]
|
||||||
Overflow,
|
Overflow,
|
||||||
|
|
||||||
/// Continuation has not started.
|
/// Continuation has not started.
|
||||||
#[display(fmt = "continuation has not started")]
|
#[display("continuation has not started")]
|
||||||
ContinuationNotStarted,
|
ContinuationNotStarted,
|
||||||
|
|
||||||
/// Received new continuation but it is already started.
|
/// Received new continuation but it is already started.
|
||||||
#[display(fmt = "received new continuation but it has already started")]
|
#[display("received new continuation but it has already started")]
|
||||||
ContinuationStarted,
|
ContinuationStarted,
|
||||||
|
|
||||||
/// Unknown continuation fragment.
|
/// Unknown continuation fragment.
|
||||||
#[display(fmt = "unknown continuation fragment: {}", _0)]
|
#[display("unknown continuation fragment: {}", _0)]
|
||||||
ContinuationFragment(#[error(not(source))] OpCode),
|
ContinuationFragment(#[error(not(source))] OpCode),
|
||||||
|
|
||||||
/// I/O error.
|
/// I/O error.
|
||||||
#[display(fmt = "I/O error: {}", _0)]
|
#[display("I/O error: {}", _0)]
|
||||||
Io(io::Error),
|
Io(io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,27 +71,27 @@ pub enum ProtocolError {
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Display, Error)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Display, Error)]
|
||||||
pub enum HandshakeError {
|
pub enum HandshakeError {
|
||||||
/// Only get method is allowed.
|
/// Only get method is allowed.
|
||||||
#[display(fmt = "method not allowed")]
|
#[display("method not allowed")]
|
||||||
GetMethodRequired,
|
GetMethodRequired,
|
||||||
|
|
||||||
/// Upgrade header if not set to WebSocket.
|
/// Upgrade header if not set to WebSocket.
|
||||||
#[display(fmt = "WebSocket upgrade is expected")]
|
#[display("WebSocket upgrade is expected")]
|
||||||
NoWebsocketUpgrade,
|
NoWebsocketUpgrade,
|
||||||
|
|
||||||
/// Connection header is not set to upgrade.
|
/// Connection header is not set to upgrade.
|
||||||
#[display(fmt = "connection upgrade is expected")]
|
#[display("connection upgrade is expected")]
|
||||||
NoConnectionUpgrade,
|
NoConnectionUpgrade,
|
||||||
|
|
||||||
/// WebSocket version header is not set.
|
/// WebSocket version header is not set.
|
||||||
#[display(fmt = "WebSocket version header is required")]
|
#[display("WebSocket version header is required")]
|
||||||
NoVersionHeader,
|
NoVersionHeader,
|
||||||
|
|
||||||
/// Unsupported WebSocket version.
|
/// Unsupported WebSocket version.
|
||||||
#[display(fmt = "unsupported WebSocket version")]
|
#[display("unsupported WebSocket version")]
|
||||||
UnsupportedVersion,
|
UnsupportedVersion,
|
||||||
|
|
||||||
/// WebSocket key is not set or wrong.
|
/// WebSocket key is not set or wrong.
|
||||||
#[display(fmt = "unknown WebSocket key")]
|
#[display("unknown WebSocket key")]
|
||||||
BadWebsocketKey,
|
BadWebsocketKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ use actix_http_test::test_server;
|
||||||
use actix_service::ServiceFactoryExt;
|
use actix_service::ServiceFactoryExt;
|
||||||
use actix_utils::future;
|
use actix_utils::future;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use derive_more::{Display, Error};
|
use derive_more::derive::{Display, Error};
|
||||||
use futures_util::StreamExt as _;
|
use futures_util::StreamExt as _;
|
||||||
|
|
||||||
const STR: &str = "Hello World Hello World Hello World Hello World Hello World \
|
const STR: &str = "Hello World Hello World Hello World Hello World Hello World \
|
||||||
|
@ -94,7 +94,7 @@ async fn with_query_parameter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Display, Error)]
|
#[derive(Debug, Display, Error)]
|
||||||
#[display(fmt = "expect failed")]
|
#[display("expect failed")]
|
||||||
struct ExpectFailed;
|
struct ExpectFailed;
|
||||||
|
|
||||||
impl From<ExpectFailed> for Response<BoxBody> {
|
impl From<ExpectFailed> for Response<BoxBody> {
|
||||||
|
|
|
@ -14,7 +14,7 @@ use actix_http_test::test_server;
|
||||||
use actix_service::{fn_service, ServiceFactoryExt};
|
use actix_service::{fn_service, ServiceFactoryExt};
|
||||||
use actix_utils::future::{err, ok, ready};
|
use actix_utils::future::{err, ok, ready};
|
||||||
use bytes::{Bytes, BytesMut};
|
use bytes::{Bytes, BytesMut};
|
||||||
use derive_more::{Display, Error};
|
use derive_more::derive::{Display, Error};
|
||||||
use futures_core::Stream;
|
use futures_core::Stream;
|
||||||
use futures_util::{stream::once, StreamExt as _};
|
use futures_util::{stream::once, StreamExt as _};
|
||||||
use openssl::{
|
use openssl::{
|
||||||
|
@ -398,7 +398,7 @@ async fn h2_response_http_error_handling() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Display, Error)]
|
#[derive(Debug, Display, Error)]
|
||||||
#[display(fmt = "error")]
|
#[display("error")]
|
||||||
struct BadRequest;
|
struct BadRequest;
|
||||||
|
|
||||||
impl From<BadRequest> for Response<BoxBody> {
|
impl From<BadRequest> for Response<BoxBody> {
|
||||||
|
|
|
@ -23,7 +23,7 @@ use actix_service::{fn_factory_with_config, fn_service};
|
||||||
use actix_tls::connect::rustls_0_23::webpki_roots_cert_store;
|
use actix_tls::connect::rustls_0_23::webpki_roots_cert_store;
|
||||||
use actix_utils::future::{err, ok, poll_fn};
|
use actix_utils::future::{err, ok, poll_fn};
|
||||||
use bytes::{Bytes, BytesMut};
|
use bytes::{Bytes, BytesMut};
|
||||||
use derive_more::{Display, Error};
|
use derive_more::derive::{Display, Error};
|
||||||
use futures_core::{ready, Stream};
|
use futures_core::{ready, Stream};
|
||||||
use futures_util::stream::once;
|
use futures_util::stream::once;
|
||||||
use rustls::{pki_types::ServerName, ServerConfig as RustlsServerConfig};
|
use rustls::{pki_types::ServerName, ServerConfig as RustlsServerConfig};
|
||||||
|
@ -480,7 +480,7 @@ async fn h2_response_http_error_handling() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Display, Error)]
|
#[derive(Debug, Display, Error)]
|
||||||
#[display(fmt = "error")]
|
#[display("error")]
|
||||||
struct BadRequest;
|
struct BadRequest;
|
||||||
|
|
||||||
impl From<BadRequest> for Response<BoxBody> {
|
impl From<BadRequest> for Response<BoxBody> {
|
||||||
|
|
|
@ -14,7 +14,7 @@ use actix_rt::{net::TcpStream, time::sleep};
|
||||||
use actix_service::fn_service;
|
use actix_service::fn_service;
|
||||||
use actix_utils::future::{err, ok, ready};
|
use actix_utils::future::{err, ok, ready};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use derive_more::{Display, Error};
|
use derive_more::derive::{Display, Error};
|
||||||
use futures_util::{stream::once, FutureExt as _, StreamExt as _};
|
use futures_util::{stream::once, FutureExt as _, StreamExt as _};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ async fn h1_2() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Display, Error)]
|
#[derive(Debug, Display, Error)]
|
||||||
#[display(fmt = "expect failed")]
|
#[display("expect failed")]
|
||||||
struct ExpectFailed;
|
struct ExpectFailed;
|
||||||
|
|
||||||
impl From<ExpectFailed> for Response<BoxBody> {
|
impl From<ExpectFailed> for Response<BoxBody> {
|
||||||
|
@ -723,7 +723,7 @@ async fn h1_response_http_error_handling() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Display, Error)]
|
#[derive(Debug, Display, Error)]
|
||||||
#[display(fmt = "error")]
|
#[display("error")]
|
||||||
struct BadRequest;
|
struct BadRequest;
|
||||||
|
|
||||||
impl From<BadRequest> for Response<BoxBody> {
|
impl From<BadRequest> for Response<BoxBody> {
|
||||||
|
|
|
@ -14,7 +14,7 @@ use actix_http::{
|
||||||
use actix_http_test::test_server;
|
use actix_http_test::test_server;
|
||||||
use actix_service::{fn_factory, Service};
|
use actix_service::{fn_factory, Service};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use derive_more::{Display, Error, From};
|
use derive_more::derive::{Display, Error, From};
|
||||||
use futures_core::future::LocalBoxFuture;
|
use futures_core::future::LocalBoxFuture;
|
||||||
use futures_util::{SinkExt as _, StreamExt as _};
|
use futures_util::{SinkExt as _, StreamExt as _};
|
||||||
|
|
||||||
|
@ -37,16 +37,16 @@ impl WsService {
|
||||||
|
|
||||||
#[derive(Debug, Display, Error, From)]
|
#[derive(Debug, Display, Error, From)]
|
||||||
enum WsServiceError {
|
enum WsServiceError {
|
||||||
#[display(fmt = "HTTP error")]
|
#[display("HTTP error")]
|
||||||
Http(actix_http::Error),
|
Http(actix_http::Error),
|
||||||
|
|
||||||
#[display(fmt = "WS handshake error")]
|
#[display("WS handshake error")]
|
||||||
Ws(actix_http::ws::HandshakeError),
|
Ws(actix_http::ws::HandshakeError),
|
||||||
|
|
||||||
#[display(fmt = "I/O error")]
|
#[display("I/O error")]
|
||||||
Io(std::io::Error),
|
Io(std::io::Error),
|
||||||
|
|
||||||
#[display(fmt = "dispatcher error")]
|
#[display("dispatcher error")]
|
||||||
Dispatcher,
|
Dispatcher,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
- Minimum supported Rust version (MSRV) is now 1.75.
|
||||||
|
|
||||||
## 0.7.2
|
## 0.7.2
|
||||||
|
|
||||||
- Fix re-exported version of `actix-multipart-derive`.
|
- Fix re-exported version of `actix-multipart-derive`.
|
||||||
|
|
|
@ -42,7 +42,7 @@ actix-multipart-derive = { version = "=0.7.0", optional = true }
|
||||||
actix-utils = "3"
|
actix-utils = "3"
|
||||||
actix-web = { version = "4", default-features = false }
|
actix-web = { version = "4", default-features = false }
|
||||||
|
|
||||||
derive_more = "0.99.5"
|
derive_more = { version = "1", features = ["display", "error", "from"] }
|
||||||
futures-core = { version = "0.3.17", default-features = false, features = ["alloc"] }
|
futures-core = { version = "0.3.17", default-features = false, features = ["alloc"] }
|
||||||
futures-util = { version = "0.3.17", default-features = false, features = ["alloc"] }
|
futures-util = { version = "0.3.17", default-features = false, features = ["alloc"] }
|
||||||
httparse = "1.3"
|
httparse = "1.3"
|
||||||
|
|
|
@ -5,18 +5,18 @@ use actix_web::{
|
||||||
http::StatusCode,
|
http::StatusCode,
|
||||||
ResponseError,
|
ResponseError,
|
||||||
};
|
};
|
||||||
use derive_more::{Display, Error, From};
|
use derive_more::derive::{Display, Error, From};
|
||||||
|
|
||||||
/// A set of errors that can occur during parsing multipart streams.
|
/// A set of errors that can occur during parsing multipart streams.
|
||||||
#[derive(Debug, Display, From, Error)]
|
#[derive(Debug, Display, From, Error)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Could not find Content-Type header.
|
/// Could not find Content-Type header.
|
||||||
#[display(fmt = "Could not find Content-Type header")]
|
#[display("Could not find Content-Type header")]
|
||||||
ContentTypeMissing,
|
ContentTypeMissing,
|
||||||
|
|
||||||
/// Could not parse Content-Type header.
|
/// Could not parse Content-Type header.
|
||||||
#[display(fmt = "Could not parse Content-Type header")]
|
#[display("Could not parse Content-Type header")]
|
||||||
ContentTypeParse,
|
ContentTypeParse,
|
||||||
|
|
||||||
/// Parsed Content-Type did not have "multipart" top-level media type.
|
/// Parsed Content-Type did not have "multipart" top-level media type.
|
||||||
|
@ -25,11 +25,11 @@ pub enum Error {
|
||||||
/// "multipart/form-data" media type.
|
/// "multipart/form-data" media type.
|
||||||
///
|
///
|
||||||
/// [`MultipartForm`]: struct@crate::form::MultipartForm
|
/// [`MultipartForm`]: struct@crate::form::MultipartForm
|
||||||
#[display(fmt = "Parsed Content-Type did not have "multipart" top-level media type")]
|
#[display("Parsed Content-Type did not have 'multipart' top-level media type")]
|
||||||
ContentTypeIncompatible,
|
ContentTypeIncompatible,
|
||||||
|
|
||||||
/// Multipart boundary is not found.
|
/// Multipart boundary is not found.
|
||||||
#[display(fmt = "Multipart boundary is not found")]
|
#[display("Multipart boundary is not found")]
|
||||||
BoundaryMissing,
|
BoundaryMissing,
|
||||||
|
|
||||||
/// Content-Disposition header was not found or not of disposition type "form-data" when parsing
|
/// Content-Disposition header was not found or not of disposition type "form-data" when parsing
|
||||||
|
@ -39,7 +39,7 @@ pub enum Error {
|
||||||
/// always be present and have a disposition type of "form-data".
|
/// always be present and have a disposition type of "form-data".
|
||||||
///
|
///
|
||||||
/// [RFC 7578 §4.2]: https://datatracker.ietf.org/doc/html/rfc7578#section-4.2
|
/// [RFC 7578 §4.2]: https://datatracker.ietf.org/doc/html/rfc7578#section-4.2
|
||||||
#[display(fmt = "Content-Disposition header was not found when parsing a \"form-data\" field")]
|
#[display("Content-Disposition header was not found when parsing a \"form-data\" field")]
|
||||||
ContentDispositionMissing,
|
ContentDispositionMissing,
|
||||||
|
|
||||||
/// Content-Disposition name parameter was not found when parsing a "form-data" field.
|
/// Content-Disposition name parameter was not found when parsing a "form-data" field.
|
||||||
|
@ -48,48 +48,48 @@ pub enum Error {
|
||||||
/// always include a "name" parameter.
|
/// always include a "name" parameter.
|
||||||
///
|
///
|
||||||
/// [RFC 7578 §4.2]: https://datatracker.ietf.org/doc/html/rfc7578#section-4.2
|
/// [RFC 7578 §4.2]: https://datatracker.ietf.org/doc/html/rfc7578#section-4.2
|
||||||
#[display(fmt = "Content-Disposition header was not found when parsing a \"form-data\" field")]
|
#[display("Content-Disposition header was not found when parsing a \"form-data\" field")]
|
||||||
ContentDispositionNameMissing,
|
ContentDispositionNameMissing,
|
||||||
|
|
||||||
/// Nested multipart is not supported.
|
/// Nested multipart is not supported.
|
||||||
#[display(fmt = "Nested multipart is not supported")]
|
#[display("Nested multipart is not supported")]
|
||||||
Nested,
|
Nested,
|
||||||
|
|
||||||
/// Multipart stream is incomplete.
|
/// Multipart stream is incomplete.
|
||||||
#[display(fmt = "Multipart stream is incomplete")]
|
#[display("Multipart stream is incomplete")]
|
||||||
Incomplete,
|
Incomplete,
|
||||||
|
|
||||||
/// Field parsing failed.
|
/// Field parsing failed.
|
||||||
#[display(fmt = "Error during field parsing")]
|
#[display("Error during field parsing")]
|
||||||
Parse(ParseError),
|
Parse(ParseError),
|
||||||
|
|
||||||
/// HTTP payload error.
|
/// HTTP payload error.
|
||||||
#[display(fmt = "Payload error")]
|
#[display("Payload error")]
|
||||||
Payload(PayloadError),
|
Payload(PayloadError),
|
||||||
|
|
||||||
/// Stream is not consumed.
|
/// Stream is not consumed.
|
||||||
#[display(fmt = "Stream is not consumed")]
|
#[display("Stream is not consumed")]
|
||||||
NotConsumed,
|
NotConsumed,
|
||||||
|
|
||||||
/// Form field handler raised error.
|
/// Form field handler raised error.
|
||||||
#[display(fmt = "An error occurred processing field: {name}")]
|
#[display("An error occurred processing field: {name}")]
|
||||||
Field {
|
Field {
|
||||||
name: String,
|
name: String,
|
||||||
source: actix_web::Error,
|
source: actix_web::Error,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Duplicate field found (for structure that opted-in to denying duplicate fields).
|
/// Duplicate field found (for structure that opted-in to denying duplicate fields).
|
||||||
#[display(fmt = "Duplicate field found: {_0}")]
|
#[display("Duplicate field found: {_0}")]
|
||||||
#[from(ignore)]
|
#[from(ignore)]
|
||||||
DuplicateField(#[error(not(source))] String),
|
DuplicateField(#[error(not(source))] String),
|
||||||
|
|
||||||
/// Required field is missing.
|
/// Required field is missing.
|
||||||
#[display(fmt = "Required field is missing: {_0}")]
|
#[display("Required field is missing: {_0}")]
|
||||||
#[from(ignore)]
|
#[from(ignore)]
|
||||||
MissingField(#[error(not(source))] String),
|
MissingField(#[error(not(source))] String),
|
||||||
|
|
||||||
/// Unknown field (for structure that opted-in to denying unknown fields).
|
/// Unknown field (for structure that opted-in to denying unknown fields).
|
||||||
#[display(fmt = "Unknown field: {_0}")]
|
#[display("Unknown field: {_0}")]
|
||||||
#[from(ignore)]
|
#[from(ignore)]
|
||||||
UnknownField(#[error(not(source))] String),
|
UnknownField(#[error(not(source))] String),
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ use actix_web::{
|
||||||
http::header::{self, ContentDisposition, HeaderMap},
|
http::header::{self, ContentDisposition, HeaderMap},
|
||||||
web::{Bytes, BytesMut},
|
web::{Bytes, BytesMut},
|
||||||
};
|
};
|
||||||
use derive_more::{Display, Error};
|
use derive_more::derive::{Display, Error};
|
||||||
use futures_core::Stream;
|
use futures_core::Stream;
|
||||||
use mime::Mime;
|
use mime::Mime;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ use crate::{
|
||||||
|
|
||||||
/// Error type returned from [`Field::bytes()`] when field data is larger than limit.
|
/// Error type returned from [`Field::bytes()`] when field data is larger than limit.
|
||||||
#[derive(Debug, Display, Error)]
|
#[derive(Debug, Display, Error)]
|
||||||
#[display(fmt = "size limit exceeded while collecting field data")]
|
#[display("size limit exceeded while collecting field data")]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub struct LimitExceeded;
|
pub struct LimitExceeded;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use actix_web::{http::StatusCode, web, Error, HttpRequest, ResponseError};
|
use actix_web::{http::StatusCode, web, Error, HttpRequest, ResponseError};
|
||||||
use derive_more::{Deref, DerefMut, Display, Error};
|
use derive_more::derive::{Deref, DerefMut, Display, Error};
|
||||||
use futures_core::future::LocalBoxFuture;
|
use futures_core::future::LocalBoxFuture;
|
||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
|
|
||||||
|
@ -66,11 +66,11 @@ where
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum JsonFieldError {
|
pub enum JsonFieldError {
|
||||||
/// Deserialize error.
|
/// Deserialize error.
|
||||||
#[display(fmt = "Json deserialize error: {}", _0)]
|
#[display("Json deserialize error: {}", _0)]
|
||||||
Deserialize(serde_json::Error),
|
Deserialize(serde_json::Error),
|
||||||
|
|
||||||
/// Content type error.
|
/// Content type error.
|
||||||
#[display(fmt = "Content type error")]
|
#[display("Content type error")]
|
||||||
ContentType,
|
ContentType,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use actix_web::{dev, error::PayloadError, web, Error, FromRequest, HttpRequest};
|
use actix_web::{dev, error::PayloadError, web, Error, FromRequest, HttpRequest};
|
||||||
use derive_more::{Deref, DerefMut};
|
use derive_more::derive::{Deref, DerefMut};
|
||||||
use futures_core::future::LocalBoxFuture;
|
use futures_core::future::LocalBoxFuture;
|
||||||
use futures_util::{TryFutureExt as _, TryStreamExt as _};
|
use futures_util::{TryFutureExt as _, TryStreamExt as _};
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use actix_web::{http::StatusCode, web, Error, HttpRequest, ResponseError};
|
use actix_web::{http::StatusCode, web, Error, HttpRequest, ResponseError};
|
||||||
use derive_more::{Display, Error};
|
use derive_more::derive::{Display, Error};
|
||||||
use futures_core::future::LocalBoxFuture;
|
use futures_core::future::LocalBoxFuture;
|
||||||
use futures_util::TryStreamExt as _;
|
use futures_util::TryStreamExt as _;
|
||||||
use mime::Mime;
|
use mime::Mime;
|
||||||
|
@ -82,7 +82,7 @@ impl<'t> FieldReader<'t> for TempFile {
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum TempFileError {
|
pub enum TempFileError {
|
||||||
/// File I/O Error
|
/// File I/O Error
|
||||||
#[display(fmt = "File I/O error: {}", _0)]
|
#[display("File I/O error: {}", _0)]
|
||||||
FileIo(std::io::Error),
|
FileIo(std::io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
use std::{str, sync::Arc};
|
use std::{str, sync::Arc};
|
||||||
|
|
||||||
use actix_web::{http::StatusCode, web, Error, HttpRequest, ResponseError};
|
use actix_web::{http::StatusCode, web, Error, HttpRequest, ResponseError};
|
||||||
use derive_more::{Deref, DerefMut, Display, Error};
|
use derive_more::derive::{Deref, DerefMut, Display, Error};
|
||||||
use futures_core::future::LocalBoxFuture;
|
use futures_core::future::LocalBoxFuture;
|
||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
|
|
||||||
|
@ -77,15 +77,15 @@ where
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum TextError {
|
pub enum TextError {
|
||||||
/// UTF-8 decoding error.
|
/// UTF-8 decoding error.
|
||||||
#[display(fmt = "UTF-8 decoding error: {}", _0)]
|
#[display("UTF-8 decoding error: {}", _0)]
|
||||||
Utf8Error(str::Utf8Error),
|
Utf8Error(str::Utf8Error),
|
||||||
|
|
||||||
/// Deserialize error.
|
/// Deserialize error.
|
||||||
#[display(fmt = "Plain text deserialize error: {}", _0)]
|
#[display("Plain text deserialize error: {}", _0)]
|
||||||
Deserialize(serde_plain::Error),
|
Deserialize(serde_plain::Error),
|
||||||
|
|
||||||
/// Content type error.
|
/// Content type error.
|
||||||
#[display(fmt = "Content type error")]
|
#[display("Content type error")]
|
||||||
ContentType,
|
ContentType,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
- Minimum supported Rust version (MSRV) is now 1.75.
|
||||||
|
|
||||||
## 4.9.0
|
## 4.9.0
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -146,7 +146,7 @@ bytes = "1"
|
||||||
bytestring = "1"
|
bytestring = "1"
|
||||||
cfg-if = "1"
|
cfg-if = "1"
|
||||||
cookie = { version = "0.16", features = ["percent-encode"], optional = true }
|
cookie = { version = "0.16", features = ["percent-encode"], optional = true }
|
||||||
derive_more = "0.99.8"
|
derive_more = { version = "1", features = ["display", "error", "from"] }
|
||||||
encoding_rs = "0.8"
|
encoding_rs = "0.8"
|
||||||
futures-core = { version = "0.3.17", default-features = false }
|
futures-core = { version = "0.3.17", default-features = false }
|
||||||
futures-util = { version = "0.3.17", default-features = false }
|
futures-util = { version = "0.3.17", default-features = false }
|
||||||
|
@ -182,7 +182,7 @@ futures-util = { version = "0.3.17", default-features = false, features = ["std"
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
rcgen = "0.13"
|
rcgen = "0.13"
|
||||||
rustls-pemfile = "2"
|
rustls-pemfile = "2"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
static_assertions = "1"
|
static_assertions = "1"
|
||||||
tls-openssl = { package = "openssl", version = "0.10.55" }
|
tls-openssl = { package = "openssl", version = "0.10.55" }
|
||||||
tls-rustls = { package = "rustls", version = "0.23" }
|
tls-rustls = { package = "rustls", version = "0.23" }
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
//
|
//
|
||||||
// See <https://github.com/rust-lang/rust/issues/83375>
|
// See <https://github.com/rust-lang/rust/issues/83375>
|
||||||
pub use actix_http::error::{ContentTypeError, DispatchError, HttpError, ParseError, PayloadError};
|
pub use actix_http::error::{ContentTypeError, DispatchError, HttpError, ParseError, PayloadError};
|
||||||
use derive_more::{Display, Error, From};
|
use derive_more::derive::{Display, Error, From};
|
||||||
use serde_json::error::Error as JsonError;
|
use serde_json::error::Error as JsonError;
|
||||||
use serde_urlencoded::{de::Error as FormDeError, ser::Error as FormError};
|
use serde_urlencoded::{de::Error as FormDeError, ser::Error as FormError};
|
||||||
use url::ParseError as UrlParseError;
|
use url::ParseError as UrlParseError;
|
||||||
|
@ -29,7 +29,7 @@ pub type Result<T, E = Error> = std::result::Result<T, E>;
|
||||||
|
|
||||||
/// An error representing a problem running a blocking task on a thread pool.
|
/// An error representing a problem running a blocking task on a thread pool.
|
||||||
#[derive(Debug, Display, Error)]
|
#[derive(Debug, Display, Error)]
|
||||||
#[display(fmt = "Blocking thread pool is shut down unexpectedly")]
|
#[display("Blocking thread pool is shut down unexpectedly")]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub struct BlockingError;
|
pub struct BlockingError;
|
||||||
|
|
||||||
|
@ -40,15 +40,15 @@ impl ResponseError for crate::error::BlockingError {}
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum UrlGenerationError {
|
pub enum UrlGenerationError {
|
||||||
/// Resource not found.
|
/// Resource not found.
|
||||||
#[display(fmt = "Resource not found")]
|
#[display("Resource not found")]
|
||||||
ResourceNotFound,
|
ResourceNotFound,
|
||||||
|
|
||||||
/// Not all URL parameters covered.
|
/// Not all URL parameters covered.
|
||||||
#[display(fmt = "Not all URL parameters covered")]
|
#[display("Not all URL parameters covered")]
|
||||||
NotEnoughElements,
|
NotEnoughElements,
|
||||||
|
|
||||||
/// URL parse error.
|
/// URL parse error.
|
||||||
#[display(fmt = "{}", _0)]
|
#[display("{}", _0)]
|
||||||
ParseError(UrlParseError),
|
ParseError(UrlParseError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,39 +59,39 @@ impl ResponseError for UrlGenerationError {}
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum UrlencodedError {
|
pub enum UrlencodedError {
|
||||||
/// Can not decode chunked transfer encoding.
|
/// Can not decode chunked transfer encoding.
|
||||||
#[display(fmt = "Can not decode chunked transfer encoding.")]
|
#[display("Can not decode chunked transfer encoding.")]
|
||||||
Chunked,
|
Chunked,
|
||||||
|
|
||||||
/// Payload size is larger than allowed. (default limit: 256kB).
|
/// Payload size is larger than allowed. (default limit: 256kB).
|
||||||
#[display(
|
#[display(
|
||||||
fmt = "URL encoded payload is larger ({} bytes) than allowed (limit: {} bytes).",
|
"URL encoded payload is larger ({} bytes) than allowed (limit: {} bytes).",
|
||||||
size,
|
size,
|
||||||
limit
|
limit
|
||||||
)]
|
)]
|
||||||
Overflow { size: usize, limit: usize },
|
Overflow { size: usize, limit: usize },
|
||||||
|
|
||||||
/// Payload size is now known.
|
/// Payload size is now known.
|
||||||
#[display(fmt = "Payload size is now known.")]
|
#[display("Payload size is now known.")]
|
||||||
UnknownLength,
|
UnknownLength,
|
||||||
|
|
||||||
/// Content type error.
|
/// Content type error.
|
||||||
#[display(fmt = "Content type error.")]
|
#[display("Content type error.")]
|
||||||
ContentType,
|
ContentType,
|
||||||
|
|
||||||
/// Parse error.
|
/// Parse error.
|
||||||
#[display(fmt = "Parse error: {}.", _0)]
|
#[display("Parse error: {}.", _0)]
|
||||||
Parse(FormDeError),
|
Parse(FormDeError),
|
||||||
|
|
||||||
/// Encoding error.
|
/// Encoding error.
|
||||||
#[display(fmt = "Encoding error.")]
|
#[display("Encoding error.")]
|
||||||
Encoding,
|
Encoding,
|
||||||
|
|
||||||
/// Serialize error.
|
/// Serialize error.
|
||||||
#[display(fmt = "Serialize error: {}.", _0)]
|
#[display("Serialize error: {}.", _0)]
|
||||||
Serialize(FormError),
|
Serialize(FormError),
|
||||||
|
|
||||||
/// Payload error.
|
/// Payload error.
|
||||||
#[display(fmt = "Error that occur during reading payload: {}.", _0)]
|
#[display("Error that occur during reading payload: {}.", _0)]
|
||||||
Payload(PayloadError),
|
Payload(PayloadError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,30 +113,30 @@ impl ResponseError for UrlencodedError {
|
||||||
pub enum JsonPayloadError {
|
pub enum JsonPayloadError {
|
||||||
/// Payload size is bigger than allowed & content length header set. (default: 2MB)
|
/// Payload size is bigger than allowed & content length header set. (default: 2MB)
|
||||||
#[display(
|
#[display(
|
||||||
fmt = "JSON payload ({} bytes) is larger than allowed (limit: {} bytes).",
|
"JSON payload ({} bytes) is larger than allowed (limit: {} bytes).",
|
||||||
length,
|
length,
|
||||||
limit
|
limit
|
||||||
)]
|
)]
|
||||||
OverflowKnownLength { length: usize, limit: usize },
|
OverflowKnownLength { length: usize, limit: usize },
|
||||||
|
|
||||||
/// Payload size is bigger than allowed but no content length header set. (default: 2MB)
|
/// Payload size is bigger than allowed but no content length header set. (default: 2MB)
|
||||||
#[display(fmt = "JSON payload has exceeded limit ({} bytes).", limit)]
|
#[display("JSON payload has exceeded limit ({} bytes).", limit)]
|
||||||
Overflow { limit: usize },
|
Overflow { limit: usize },
|
||||||
|
|
||||||
/// Content type error
|
/// Content type error
|
||||||
#[display(fmt = "Content type error")]
|
#[display("Content type error")]
|
||||||
ContentType,
|
ContentType,
|
||||||
|
|
||||||
/// Deserialize error
|
/// Deserialize error
|
||||||
#[display(fmt = "Json deserialize error: {}", _0)]
|
#[display("Json deserialize error: {}", _0)]
|
||||||
Deserialize(JsonError),
|
Deserialize(JsonError),
|
||||||
|
|
||||||
/// Serialize error
|
/// Serialize error
|
||||||
#[display(fmt = "Json serialize error: {}", _0)]
|
#[display("Json serialize error: {}", _0)]
|
||||||
Serialize(JsonError),
|
Serialize(JsonError),
|
||||||
|
|
||||||
/// Payload error
|
/// Payload error
|
||||||
#[display(fmt = "Error that occur during reading payload: {}", _0)]
|
#[display("Error that occur during reading payload: {}", _0)]
|
||||||
Payload(PayloadError),
|
Payload(PayloadError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ impl ResponseError for JsonPayloadError {
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum PathError {
|
pub enum PathError {
|
||||||
/// Deserialize error
|
/// Deserialize error
|
||||||
#[display(fmt = "Path deserialize error: {}", _0)]
|
#[display("Path deserialize error: {}", _0)]
|
||||||
Deserialize(serde::de::value::Error),
|
Deserialize(serde::de::value::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ impl ResponseError for PathError {
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum QueryPayloadError {
|
pub enum QueryPayloadError {
|
||||||
/// Query deserialize error.
|
/// Query deserialize error.
|
||||||
#[display(fmt = "Query deserialize error: {}", _0)]
|
#[display("Query deserialize error: {}", _0)]
|
||||||
Deserialize(serde::de::value::Error),
|
Deserialize(serde::de::value::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,20 +196,20 @@ impl ResponseError for QueryPayloadError {
|
||||||
#[derive(Debug, Display, Error, From)]
|
#[derive(Debug, Display, Error, From)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum ReadlinesError {
|
pub enum ReadlinesError {
|
||||||
#[display(fmt = "Encoding error")]
|
#[display("Encoding error")]
|
||||||
/// Payload size is bigger than allowed. (default: 256kB)
|
/// Payload size is bigger than allowed. (default: 256kB)
|
||||||
EncodingError,
|
EncodingError,
|
||||||
|
|
||||||
/// Payload error.
|
/// Payload error.
|
||||||
#[display(fmt = "Error that occur during reading payload: {}", _0)]
|
#[display("Error that occur during reading payload: {}", _0)]
|
||||||
Payload(PayloadError),
|
Payload(PayloadError),
|
||||||
|
|
||||||
/// Line limit exceeded.
|
/// Line limit exceeded.
|
||||||
#[display(fmt = "Line limit exceeded")]
|
#[display("Line limit exceeded")]
|
||||||
LimitOverflow,
|
LimitOverflow,
|
||||||
|
|
||||||
/// ContentType error.
|
/// ContentType error.
|
||||||
#[display(fmt = "Content-type error")]
|
#[display("Content-type error")]
|
||||||
ContentTypeError(ContentTypeError),
|
ContentTypeError(ContentTypeError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::{convert::Infallible, str};
|
use std::{convert::Infallible, str};
|
||||||
|
|
||||||
use derive_more::{Deref, DerefMut};
|
use derive_more::derive::{Deref, DerefMut};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::ParseError,
|
error::ParseError,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::{convert::Infallible, net::SocketAddr};
|
use std::{convert::Infallible, net::SocketAddr};
|
||||||
|
|
||||||
use actix_utils::future::{err, ok, Ready};
|
use actix_utils::future::{err, ok, Ready};
|
||||||
use derive_more::{Display, Error};
|
use derive_more::derive::{Display, Error};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
dev::{AppConfig, Payload, RequestHead},
|
dev::{AppConfig, Payload, RequestHead},
|
||||||
|
@ -235,7 +235,7 @@ impl FromRequest for ConnectionInfo {
|
||||||
/// # let _svc = actix_web::web::to(handler);
|
/// # let _svc = actix_web::web::to(handler);
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Display)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Display)]
|
||||||
#[display(fmt = "{}", _0)]
|
#[display("{}", _0)]
|
||||||
pub struct PeerAddr(pub SocketAddr);
|
pub struct PeerAddr(pub SocketAddr);
|
||||||
|
|
||||||
impl PeerAddr {
|
impl PeerAddr {
|
||||||
|
@ -247,7 +247,7 @@ impl PeerAddr {
|
||||||
|
|
||||||
#[derive(Debug, Display, Error)]
|
#[derive(Debug, Display, Error)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[display(fmt = "Missing peer address")]
|
#[display("Missing peer address")]
|
||||||
pub struct MissingPeerAddr;
|
pub struct MissingPeerAddr;
|
||||||
|
|
||||||
impl ResponseError for MissingPeerAddr {}
|
impl ResponseError for MissingPeerAddr {}
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use actix_router::PathDeserializer;
|
use actix_router::PathDeserializer;
|
||||||
use actix_utils::future::{ready, Ready};
|
use actix_utils::future::{ready, Ready};
|
||||||
use derive_more::{AsRef, Deref, DerefMut, Display, From};
|
use derive_more::derive::{AsRef, Deref, DerefMut, Display, From};
|
||||||
use serde::de;
|
use serde::de;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -152,14 +152,14 @@ impl PathConfig {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use actix_router::ResourceDef;
|
use actix_router::ResourceDef;
|
||||||
use derive_more::Display;
|
use derive_more::derive::Display;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{error, http, test::TestRequest, HttpResponse};
|
use crate::{error, http, test::TestRequest, HttpResponse};
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Display)]
|
#[derive(Deserialize, Debug, Display)]
|
||||||
#[display(fmt = "MyStruct({}, {})", key, value)]
|
#[display("MyStruct({}, {})", key, value)]
|
||||||
struct MyStruct {
|
struct MyStruct {
|
||||||
key: String,
|
key: String,
|
||||||
value: String,
|
value: String,
|
||||||
|
|
|
@ -187,7 +187,7 @@ impl QueryConfig {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use actix_http::StatusCode;
|
use actix_http::StatusCode;
|
||||||
use derive_more::Display;
|
use derive_more::derive::Display;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
- Minimum supported Rust version (MSRV) is now 1.75.
|
||||||
|
|
||||||
## 3.5.1
|
## 3.5.1
|
||||||
|
|
||||||
- Fix WebSocket `Host` request header value when using a non-default port.
|
- Fix WebSocket `Host` request header value when using a non-default port.
|
||||||
|
|
|
@ -106,7 +106,7 @@ actix-utils = "3"
|
||||||
base64 = "0.22"
|
base64 = "0.22"
|
||||||
bytes = "1"
|
bytes = "1"
|
||||||
cfg-if = "1"
|
cfg-if = "1"
|
||||||
derive_more = "0.99.5"
|
derive_more = { version = "1", features = ["display", "error", "from"] }
|
||||||
futures-core = { version = "0.3.17", default-features = false, features = ["alloc"] }
|
futures-core = { version = "0.3.17", default-features = false, features = ["alloc"] }
|
||||||
futures-util = { version = "0.3.17", default-features = false, features = ["alloc", "sink"] }
|
futures-util = { version = "0.3.17", default-features = false, features = ["alloc", "sink"] }
|
||||||
h2 = "0.3.26"
|
h2 = "0.3.26"
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::{fmt, io};
|
||||||
use actix_http::error::{HttpError, ParseError};
|
use actix_http::error::{HttpError, ParseError};
|
||||||
#[cfg(feature = "openssl")]
|
#[cfg(feature = "openssl")]
|
||||||
use actix_tls::accept::openssl::reexports::Error as OpensslError;
|
use actix_tls::accept::openssl::reexports::Error as OpensslError;
|
||||||
use derive_more::{Display, From};
|
use derive_more::derive::{Display, From};
|
||||||
|
|
||||||
use crate::BoxError;
|
use crate::BoxError;
|
||||||
|
|
||||||
|
@ -12,40 +12,40 @@ use crate::BoxError;
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum ConnectError {
|
pub enum ConnectError {
|
||||||
/// SSL feature is not enabled
|
/// SSL feature is not enabled
|
||||||
#[display(fmt = "SSL is not supported")]
|
#[display("SSL is not supported")]
|
||||||
SslIsNotSupported,
|
SslIsNotSupported,
|
||||||
|
|
||||||
/// SSL error
|
/// SSL error
|
||||||
#[cfg(feature = "openssl")]
|
#[cfg(feature = "openssl")]
|
||||||
#[display(fmt = "{}", _0)]
|
#[display("{}", _0)]
|
||||||
SslError(OpensslError),
|
SslError(OpensslError),
|
||||||
|
|
||||||
/// Failed to resolve the hostname
|
/// Failed to resolve the hostname
|
||||||
#[display(fmt = "Failed resolving hostname: {}", _0)]
|
#[display("Failed resolving hostname: {}", _0)]
|
||||||
Resolver(Box<dyn std::error::Error>),
|
Resolver(Box<dyn std::error::Error>),
|
||||||
|
|
||||||
/// No dns records
|
/// No dns records
|
||||||
#[display(fmt = "No DNS records found for the input")]
|
#[display("No DNS records found for the input")]
|
||||||
NoRecords,
|
NoRecords,
|
||||||
|
|
||||||
/// Http2 error
|
/// Http2 error
|
||||||
#[display(fmt = "{}", _0)]
|
#[display("{}", _0)]
|
||||||
H2(h2::Error),
|
H2(h2::Error),
|
||||||
|
|
||||||
/// Connecting took too long
|
/// Connecting took too long
|
||||||
#[display(fmt = "Timeout while establishing connection")]
|
#[display("Timeout while establishing connection")]
|
||||||
Timeout,
|
Timeout,
|
||||||
|
|
||||||
/// Connector has been disconnected
|
/// Connector has been disconnected
|
||||||
#[display(fmt = "Internal error: connector has been disconnected")]
|
#[display("Internal error: connector has been disconnected")]
|
||||||
Disconnected,
|
Disconnected,
|
||||||
|
|
||||||
/// Unresolved host name
|
/// Unresolved host name
|
||||||
#[display(fmt = "Connector received `Connect` method with unresolved host")]
|
#[display("Connector received `Connect` method with unresolved host")]
|
||||||
Unresolved,
|
Unresolved,
|
||||||
|
|
||||||
/// Connection io error
|
/// Connection io error
|
||||||
#[display(fmt = "{}", _0)]
|
#[display("{}", _0)]
|
||||||
Io(io::Error),
|
Io(io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,16 +66,16 @@ impl From<actix_tls::connect::ConnectError> for ConnectError {
|
||||||
#[derive(Debug, Display, From)]
|
#[derive(Debug, Display, From)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum InvalidUrl {
|
pub enum InvalidUrl {
|
||||||
#[display(fmt = "Missing URL scheme")]
|
#[display("Missing URL scheme")]
|
||||||
MissingScheme,
|
MissingScheme,
|
||||||
|
|
||||||
#[display(fmt = "Unknown URL scheme")]
|
#[display("Unknown URL scheme")]
|
||||||
UnknownScheme,
|
UnknownScheme,
|
||||||
|
|
||||||
#[display(fmt = "Missing host name")]
|
#[display("Missing host name")]
|
||||||
MissingHost,
|
MissingHost,
|
||||||
|
|
||||||
#[display(fmt = "URL parse error: {}", _0)]
|
#[display("URL parse error: {}", _0)]
|
||||||
HttpError(http::Error),
|
HttpError(http::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,11 +86,11 @@ impl std::error::Error for InvalidUrl {}
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum SendRequestError {
|
pub enum SendRequestError {
|
||||||
/// Invalid URL
|
/// Invalid URL
|
||||||
#[display(fmt = "Invalid URL: {}", _0)]
|
#[display("Invalid URL: {}", _0)]
|
||||||
Url(InvalidUrl),
|
Url(InvalidUrl),
|
||||||
|
|
||||||
/// Failed to connect to host
|
/// Failed to connect to host
|
||||||
#[display(fmt = "Failed to connect to host: {}", _0)]
|
#[display("Failed to connect to host: {}", _0)]
|
||||||
Connect(ConnectError),
|
Connect(ConnectError),
|
||||||
|
|
||||||
/// Error sending request
|
/// Error sending request
|
||||||
|
@ -100,26 +100,26 @@ pub enum SendRequestError {
|
||||||
Response(ParseError),
|
Response(ParseError),
|
||||||
|
|
||||||
/// Http error
|
/// Http error
|
||||||
#[display(fmt = "{}", _0)]
|
#[display("{}", _0)]
|
||||||
Http(HttpError),
|
Http(HttpError),
|
||||||
|
|
||||||
/// Http2 error
|
/// Http2 error
|
||||||
#[display(fmt = "{}", _0)]
|
#[display("{}", _0)]
|
||||||
H2(h2::Error),
|
H2(h2::Error),
|
||||||
|
|
||||||
/// Response took too long
|
/// Response took too long
|
||||||
#[display(fmt = "Timeout while waiting for response")]
|
#[display("Timeout while waiting for response")]
|
||||||
Timeout,
|
Timeout,
|
||||||
|
|
||||||
/// Tunnels are not supported for HTTP/2 connection
|
/// Tunnels are not supported for HTTP/2 connection
|
||||||
#[display(fmt = "Tunnels are not supported for http2 connection")]
|
#[display("Tunnels are not supported for http2 connection")]
|
||||||
TunnelNotSupported,
|
TunnelNotSupported,
|
||||||
|
|
||||||
/// Error sending request body
|
/// Error sending request body
|
||||||
Body(BoxError),
|
Body(BoxError),
|
||||||
|
|
||||||
/// Other errors that can occur after submitting a request.
|
/// Other errors that can occur after submitting a request.
|
||||||
#[display(fmt = "{:?}: {}", _1, _0)]
|
#[display("{:?}: {}", _1, _0)]
|
||||||
Custom(BoxError, Box<dyn fmt::Debug>),
|
Custom(BoxError, Box<dyn fmt::Debug>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,15 +130,15 @@ impl std::error::Error for SendRequestError {}
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum FreezeRequestError {
|
pub enum FreezeRequestError {
|
||||||
/// Invalid URL
|
/// Invalid URL
|
||||||
#[display(fmt = "Invalid URL: {}", _0)]
|
#[display("Invalid URL: {}", _0)]
|
||||||
Url(InvalidUrl),
|
Url(InvalidUrl),
|
||||||
|
|
||||||
/// HTTP error
|
/// HTTP error
|
||||||
#[display(fmt = "{}", _0)]
|
#[display("{}", _0)]
|
||||||
Http(HttpError),
|
Http(HttpError),
|
||||||
|
|
||||||
/// Other errors that can occur after submitting a request.
|
/// Other errors that can occur after submitting a request.
|
||||||
#[display(fmt = "{:?}: {}", _1, _0)]
|
#[display("{:?}: {}", _1, _0)]
|
||||||
Custom(BoxError, Box<dyn fmt::Debug>),
|
Custom(BoxError, Box<dyn fmt::Debug>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ pub use actix_http::{
|
||||||
ws::{HandshakeError as WsHandshakeError, ProtocolError as WsProtocolError},
|
ws::{HandshakeError as WsHandshakeError, ProtocolError as WsProtocolError},
|
||||||
StatusCode,
|
StatusCode,
|
||||||
};
|
};
|
||||||
use derive_more::{Display, From};
|
use derive_more::derive::{Display, From};
|
||||||
use serde_json::error::Error as JsonError;
|
use serde_json::error::Error as JsonError;
|
||||||
|
|
||||||
pub use crate::client::{ConnectError, FreezeRequestError, InvalidUrl, SendRequestError};
|
pub use crate::client::{ConnectError, FreezeRequestError, InvalidUrl, SendRequestError};
|
||||||
|
@ -18,35 +18,35 @@ pub use crate::client::{ConnectError, FreezeRequestError, InvalidUrl, SendReques
|
||||||
#[derive(Debug, Display, From)]
|
#[derive(Debug, Display, From)]
|
||||||
pub enum WsClientError {
|
pub enum WsClientError {
|
||||||
/// Invalid response status
|
/// Invalid response status
|
||||||
#[display(fmt = "Invalid response status")]
|
#[display("Invalid response status")]
|
||||||
InvalidResponseStatus(StatusCode),
|
InvalidResponseStatus(StatusCode),
|
||||||
|
|
||||||
/// Invalid upgrade header
|
/// Invalid upgrade header
|
||||||
#[display(fmt = "Invalid upgrade header")]
|
#[display("Invalid upgrade header")]
|
||||||
InvalidUpgradeHeader,
|
InvalidUpgradeHeader,
|
||||||
|
|
||||||
/// Invalid connection header
|
/// Invalid connection header
|
||||||
#[display(fmt = "Invalid connection header")]
|
#[display("Invalid connection header")]
|
||||||
InvalidConnectionHeader(HeaderValue),
|
InvalidConnectionHeader(HeaderValue),
|
||||||
|
|
||||||
/// Missing Connection header
|
/// Missing Connection header
|
||||||
#[display(fmt = "Missing Connection header")]
|
#[display("Missing Connection header")]
|
||||||
MissingConnectionHeader,
|
MissingConnectionHeader,
|
||||||
|
|
||||||
/// Missing Sec-Websocket-Accept header
|
/// Missing Sec-Websocket-Accept header
|
||||||
#[display(fmt = "Missing Sec-Websocket-Accept header")]
|
#[display("Missing Sec-Websocket-Accept header")]
|
||||||
MissingWebSocketAcceptHeader,
|
MissingWebSocketAcceptHeader,
|
||||||
|
|
||||||
/// Invalid challenge response
|
/// Invalid challenge response
|
||||||
#[display(fmt = "Invalid challenge response")]
|
#[display("Invalid challenge response")]
|
||||||
InvalidChallengeResponse([u8; 28], HeaderValue),
|
InvalidChallengeResponse([u8; 28], HeaderValue),
|
||||||
|
|
||||||
/// Protocol error
|
/// Protocol error
|
||||||
#[display(fmt = "{}", _0)]
|
#[display("{}", _0)]
|
||||||
Protocol(WsProtocolError),
|
Protocol(WsProtocolError),
|
||||||
|
|
||||||
/// Send request error
|
/// Send request error
|
||||||
#[display(fmt = "{}", _0)]
|
#[display("{}", _0)]
|
||||||
SendRequest(SendRequestError),
|
SendRequest(SendRequestError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,13 +68,13 @@ impl From<HttpError> for WsClientError {
|
||||||
#[derive(Debug, Display, From)]
|
#[derive(Debug, Display, From)]
|
||||||
pub enum JsonPayloadError {
|
pub enum JsonPayloadError {
|
||||||
/// Content type error
|
/// Content type error
|
||||||
#[display(fmt = "Content type error")]
|
#[display("Content type error")]
|
||||||
ContentType,
|
ContentType,
|
||||||
/// Deserialize error
|
/// Deserialize error
|
||||||
#[display(fmt = "Json deserialize error: {}", _0)]
|
#[display("Json deserialize error: {}", _0)]
|
||||||
Deserialize(JsonError),
|
Deserialize(JsonError),
|
||||||
/// Payload error
|
/// Payload error
|
||||||
#[display(fmt = "Error that occur during reading payload: {}", _0)]
|
#[display("Error that occur during reading payload: {}", _0)]
|
||||||
Payload(PayloadError),
|
Payload(PayloadError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ use actix_http::{
|
||||||
use actix_http::{encoding::Decoder, header::ContentEncoding, Payload};
|
use actix_http::{encoding::Decoder, header::ContentEncoding, Payload};
|
||||||
use actix_rt::time::{sleep, Sleep};
|
use actix_rt::time::{sleep, Sleep};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use derive_more::From;
|
use derive_more::derive::From;
|
||||||
use futures_core::Stream;
|
use futures_core::Stream;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue