1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-07-04 09:56:22 +02:00

Compare commits

...

16 Commits

46 changed files with 224 additions and 122 deletions

View File

@ -1,6 +1,6 @@
# Changes
## Unreleased - 2022-xx-xx
## Unreleased - 2023-xx-xx
## 0.6.3 - 2023-01-21

View File

@ -14,6 +14,9 @@
#![deny(rust_2018_idioms, nonstandard_style)]
#![warn(future_incompatible, missing_docs, missing_debug_implementations)]
#![allow(clippy::uninlined_format_args)]
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
use actix_service::boxed::{BoxService, BoxServiceFactory};
use actix_web::{

View File

@ -1,6 +1,6 @@
# Changes
## Unreleased - 2022-xx-xx
## Unreleased - 2023-xx-xx
## 3.1.0 - 2023-01-21

View File

@ -39,7 +39,7 @@ awc = { version = "3", default-features = false }
bytes = "1"
futures-core = { version = "0.3.17", default-features = false }
http = "0.2.5"
http = "0.2.7"
log = "0.4"
socket2 = "0.4"
serde = "1.0"
@ -47,7 +47,7 @@ serde_json = "1.0"
slab = "0.4"
serde_urlencoded = "0.7"
tls-openssl = { version = "0.10.9", package = "openssl", optional = true }
tokio = { version = "1.18.5", features = ["sync"] }
tokio = { version = "1.24.2", features = ["sync"] }
[dev-dependencies]
actix-web = { version = "4", default-features = false, features = ["cookies"] }

View File

@ -5,6 +5,7 @@
#![allow(clippy::uninlined_format_args)]
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#[cfg(feature = "openssl")]
extern crate tls_openssl as openssl;

View File

@ -1,6 +1,12 @@
# Changes
## Unreleased - 2022-xx-xx
## Unreleased - 2023-xx-xx
## 3.3.1 - 2023-03-02
### Fixed
- Use correct `http` version requirement to ensure support for const `HeaderName` definitions.
## 3.3.0 - 2023-01-21

View File

@ -1,6 +1,6 @@
[package]
name = "actix-http"
version = "3.3.0"
version = "3.3.1"
authors = [
"Nikolay Kim <fafhrd91@gmail.com>",
"Rob Ede <robjtede@icloud.com>",
@ -61,14 +61,14 @@ actix-codec = "0.5"
actix-utils = "3"
actix-rt = { version = "2.2", default-features = false }
ahash = "0.7"
ahash = "0.8"
bitflags = "1.2"
bytes = "1"
bytestring = "1"
derive_more = "0.99.5"
encoding_rs = "0.8"
futures-core = { version = "0.3.17", default-features = false, features = ["alloc"] }
http = "0.2.5"
http = "0.2.7"
httparse = "1.5.1"
httpdate = "1.0.1"
itoa = "1"
@ -77,7 +77,7 @@ mime = "0.3"
percent-encoding = "2.1"
pin-project-lite = "0.2"
smallvec = "1.6.1"
tokio = { version = "1.18.5", features = [] }
tokio = { version = "1.24.2", features = [] }
tokio-util = { version = "0.7", features = ["io", "codec"] }
tracing = { version = "0.1.30", default-features = false, features = ["log"] }
@ -119,7 +119,7 @@ serde_json = "1.0"
static_assertions = "1"
tls-openssl = { package = "openssl", version = "0.10.9" }
tls-rustls = { package = "rustls", version = "0.20.0" }
tokio = { version = "1.18.5", features = ["net", "rt", "macros"] }
tokio = { version = "1.24.2", features = ["net", "rt", "macros"] }
[[example]]
name = "ws"

View File

@ -3,11 +3,11 @@
> HTTP primitives for the Actix ecosystem.
[![crates.io](https://img.shields.io/crates/v/actix-http?label=latest)](https://crates.io/crates/actix-http)
[![Documentation](https://docs.rs/actix-http/badge.svg?version=3.3.0)](https://docs.rs/actix-http/3.3.0)
[![Documentation](https://docs.rs/actix-http/badge.svg?version=3.3.1)](https://docs.rs/actix-http/3.3.1)
![Version](https://img.shields.io/badge/rustc-1.59+-ab6000.svg)
![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-http.svg)
<br />
[![dependency status](https://deps.rs/crate/actix-http/3.3.0/status.svg)](https://deps.rs/crate/actix-http/3.3.0)
[![dependency status](https://deps.rs/crate/actix-http/3.3.1/status.svg)](https://deps.rs/crate/actix-http/3.3.1)
[![Download](https://img.shields.io/crates/d/actix-http.svg)](https://crates.io/crates/actix-http)
[![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x)

View File

@ -211,7 +211,6 @@ where
/// Finish service configuration and create a service for the HTTP/2 protocol.
#[cfg(feature = "http2")]
#[cfg_attr(docsrs, doc(cfg(feature = "http2")))]
pub fn h2<F, B>(self, service: F) -> crate::h2::H2Service<T, S, B>
where
F: IntoServiceFactory<S, Request>,

View File

@ -294,7 +294,6 @@ impl std::error::Error for PayloadError {
PayloadError::Overflow => None,
PayloadError::UnknownLength => None,
#[cfg(feature = "http2")]
#[cfg_attr(docsrs, doc(cfg(feature = "http2")))]
PayloadError::Http2Payload(err) => Some(err),
PayloadError::Io(err) => Some(err),
}
@ -352,7 +351,6 @@ pub enum DispatchError {
/// HTTP/2 error.
#[display(fmt = "{}", _0)]
#[cfg(feature = "http2")]
#[cfg_attr(docsrs, doc(cfg(feature = "http2")))]
H2(h2::Error),
/// The first request did not complete within the specified timeout.

View File

@ -134,7 +134,6 @@ mod openssl {
U::InitError: fmt::Debug,
{
/// Create OpenSSL based service.
#[cfg_attr(docsrs, doc(cfg(feature = "openssl")))]
pub fn openssl(
self,
acceptor: SslAcceptor,
@ -197,7 +196,6 @@ mod rustls {
U::InitError: fmt::Debug,
{
/// Create Rustls based service.
#[cfg_attr(docsrs, doc(cfg(feature = "rustls")))]
pub fn rustls(
self,
config: ServerConfig,

View File

@ -117,7 +117,6 @@ mod openssl {
B: MessageBody + 'static,
{
/// Create OpenSSL based service.
#[cfg_attr(docsrs, doc(cfg(feature = "openssl")))]
pub fn openssl(
self,
acceptor: SslAcceptor,
@ -165,7 +164,6 @@ mod rustls {
B: MessageBody + 'static,
{
/// Create Rustls based service.
#[cfg_attr(docsrs, doc(cfg(feature = "rustls")))]
pub fn rustls(
self,
mut config: ServerConfig,

View File

@ -8,12 +8,14 @@ use http::header::HeaderName;
/// request.
///
/// See [RFC 9211](https://www.rfc-editor.org/rfc/rfc9211) for full semantics.
// TODO(breaking): replace with http's version
pub const CACHE_STATUS: HeaderName = HeaderName::from_static("cache-status");
/// Response header field that allows origin servers to control the behavior of CDN caches
/// interposed between them and clients separately from other caches that might handle the response.
///
/// See [RFC 9213](https://www.rfc-editor.org/rfc/rfc9213) for full semantics.
// TODO(breaking): replace with http's version
pub const CDN_CACHE_CONTROL: HeaderName = HeaderName::from_static("cdn-cache-control");
/// Response header that prevents a document from loading any cross-origin resources that don't

View File

@ -26,7 +26,7 @@
)]
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
pub use ::http::{uri, uri::Uri};
pub use ::http::{Method, StatusCode, Version};
@ -41,7 +41,6 @@ pub mod error;
mod extensions;
pub mod h1;
#[cfg(feature = "http2")]
#[cfg_attr(docsrs, doc(cfg(feature = "http2")))]
pub mod h2;
pub mod header;
mod helpers;
@ -56,7 +55,6 @@ mod responses;
mod service;
pub mod test;
#[cfg(feature = "ws")]
#[cfg_attr(docsrs, doc(cfg(feature = "ws")))]
pub mod ws;
pub use self::builder::HttpServiceBuilder;
@ -74,7 +72,6 @@ pub use self::requests::{Request, RequestHead, RequestHeadType};
pub use self::responses::{Response, ResponseBuilder, ResponseHead};
pub use self::service::HttpService;
#[cfg(any(feature = "openssl", feature = "rustls"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "openssl", feature = "rustls"))))]
pub use self::service::TlsAcceptorConfig;
/// A major HTTP protocol version.

View File

@ -217,7 +217,6 @@ where
/// Creates TCP stream service from HTTP service that automatically selects HTTP/1.x or HTTP/2
/// on plaintext connections.
#[cfg(feature = "http2")]
#[cfg_attr(docsrs, doc(cfg(feature = "http2")))]
pub fn tcp_auto_h2c(
self,
) -> impl ServiceFactory<
@ -253,7 +252,6 @@ where
/// Configuration options used when accepting TLS connection.
#[cfg(any(feature = "openssl", feature = "rustls"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "openssl", feature = "rustls"))))]
#[derive(Debug, Default)]
pub struct TlsAcceptorConfig {
pub(crate) handshake_timeout: Option<std::time::Duration>,
@ -309,7 +307,6 @@ mod openssl {
U::InitError: fmt::Debug,
{
/// Create OpenSSL based service.
#[cfg_attr(docsrs, doc(cfg(feature = "openssl")))]
pub fn openssl(
self,
acceptor: SslAcceptor,
@ -324,7 +321,6 @@ mod openssl {
}
/// Create OpenSSL based service with custom TLS acceptor configuration.
#[cfg_attr(docsrs, doc(cfg(feature = "openssl")))]
pub fn openssl_with_config(
self,
acceptor: SslAcceptor,
@ -404,7 +400,6 @@ mod rustls {
U::InitError: fmt::Debug,
{
/// Create Rustls based service.
#[cfg_attr(docsrs, doc(cfg(feature = "rustls")))]
pub fn rustls(
self,
config: ServerConfig,
@ -419,7 +414,6 @@ mod rustls {
}
/// Create Rustls based service with custom TLS acceptor configuration.
#[cfg_attr(docsrs, doc(cfg(feature = "rustls")))]
pub fn rustls_with_config(
self,
mut config: ServerConfig,

View File

@ -0,0 +1,5 @@
# Changes
## 0.6.0 - 2023-02-26
- Add `MultipartForm` derive macro.

View File

@ -1,6 +1,6 @@
[package]
name = "actix-multipart-derive"
version = "0.5.0"
version = "0.6.0"
authors = ["Jacob Halsey <jacob@jhalsey.com>"]
description = "Multipart form derive macro for Actix Web"
keywords = ["http", "web", "framework", "async", "futures"]
@ -9,6 +9,10 @@ repository = "https://github.com/actix/actix-web.git"
license = "MIT OR Apache-2.0"
edition = "2018"
[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
all-features = true
[lib]
proc-macro = true
@ -20,7 +24,7 @@ quote = "1"
syn = "1"
[dev-dependencies]
actix-multipart = "0.5"
actix-multipart = "0.6"
actix-web = "4"
rustversion = "1"
trybuild = "1"

View File

@ -1,3 +1,17 @@
# actix-multipart-derive
> The derive macro implementation for actix-multipart.
> The derive macro implementation for actix-multipart-derive.
[![crates.io](https://img.shields.io/crates/v/actix-multipart-derive?label=latest)](https://crates.io/crates/actix-multipart-derive)
[![Documentation](https://docs.rs/actix-multipart-derive/badge.svg?version=0.5.0)](https://docs.rs/actix-multipart-derive/0.5.0)
![Version](https://img.shields.io/badge/rustc-1.59+-ab6000.svg)
![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-multipart-derive.svg)
<br />
[![dependency status](https://deps.rs/crate/actix-multipart-derive/0.5.0/status.svg)](https://deps.rs/crate/actix-multipart-derive/0.5.0)
[![Download](https://img.shields.io/crates/d/actix-multipart-derive.svg)](https://crates.io/crates/actix-multipart-derive)
[![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x)
## Documentation & Resources
- [API Documentation](https://docs.rs/actix-multipart-derive)
- Minimum Supported Rust Version (MSRV): 1.59

View File

@ -6,7 +6,7 @@
#![warn(future_incompatible)]
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
use std::{collections::HashSet, convert::TryFrom as _};

View File

@ -1,6 +1,8 @@
# Changes
## Unreleased - 2022-xx-xx
## Unreleased - 2023-xx-xx
## 0.6.0 - 2023-02-26
- Added `MultipartForm` typed data extractor. [#2883]

View File

@ -1,6 +1,6 @@
[package]
name = "actix-multipart"
version = "0.5.0"
version = "0.6.0"
authors = [
"Nikolay Kim <fafhrd91@gmail.com>",
"Jacob Halsey <jacob@jhalsey.com>",
@ -21,12 +21,8 @@ default = ["tempfile", "derive"]
derive = ["actix-multipart-derive"]
tempfile = ["tempfile-dep", "tokio/fs"]
[lib]
name = "actix_multipart"
path = "src/lib.rs"
[dependencies]
actix-multipart-derive = { version = "=0.5.0", optional = true }
actix-multipart-derive = { version = "=0.6.0", optional = true }
actix-utils = "3"
actix-web = { version = "4", default-features = false }
@ -44,7 +40,7 @@ serde_json = "1"
serde_plain = "1"
# TODO(MSRV 1.60): replace with dep: prefix
tempfile-dep = { package = "tempfile", version = "3.4", optional = true }
tokio = { version = "1.18.5", features = ["sync"] }
tokio = { version = "1.24.2", features = ["sync"] }
[dev-dependencies]
actix-http = "3"
@ -53,5 +49,5 @@ actix-rt = "2.2"
actix-test = "0.1"
awc = "3"
futures-util = { version = "0.3.17", default-features = false, features = ["alloc"] }
tokio = { version = "1.18.5", features = ["sync"] }
tokio = { version = "1.24.2", features = ["sync"] }
tokio-stream = "0.1"

View File

@ -3,11 +3,11 @@
> Multipart form support for Actix Web.
[![crates.io](https://img.shields.io/crates/v/actix-multipart?label=latest)](https://crates.io/crates/actix-multipart)
[![Documentation](https://docs.rs/actix-multipart/badge.svg?version=0.5.0)](https://docs.rs/actix-multipart/0.5.0)
[![Documentation](https://docs.rs/actix-multipart/badge.svg?version=0.6.0)](https://docs.rs/actix-multipart/0.6.0)
![Version](https://img.shields.io/badge/rustc-1.59+-ab6000.svg)
![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-multipart.svg)
<br />
[![dependency status](https://deps.rs/crate/actix-multipart/0.5.0/status.svg)](https://deps.rs/crate/actix-multipart/0.5.0)
[![dependency status](https://deps.rs/crate/actix-multipart/0.6.0/status.svg)](https://deps.rs/crate/actix-multipart/0.6.0)
[![Download](https://img.shields.io/crates/d/actix-multipart.svg)](https://crates.io/crates/actix-multipart)
[![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x)

View File

@ -16,12 +16,10 @@ use crate::{Field, Multipart, MultipartError};
pub mod bytes;
pub mod json;
#[cfg_attr(docsrs, doc(cfg(feature = "tempfile")))]
#[cfg(feature = "tempfile")]
pub mod tempfile;
pub mod text;
#[cfg_attr(docsrs, doc(cfg(feature = "derive")))]
#[cfg(feature = "derive")]
pub use actix_multipart_derive::MultipartForm;

View File

@ -3,7 +3,9 @@
#![deny(rust_2018_idioms, nonstandard_style)]
#![warn(future_incompatible)]
#![allow(clippy::borrow_interior_mutable_const, clippy::uninlined_format_args)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
// This allows us to use the actix_multipart_derive within this crate's tests
#[cfg(test)]

View File

@ -1,6 +1,6 @@
# Changes
## Unreleased - 2022-xx-xx
## Unreleased - 2023-xx-xx
## 0.5.1 - 2022-09-19

View File

@ -21,14 +21,14 @@ default = ["http"]
[dependencies]
bytestring = ">=0.1.5, <2"
http = { version = "0.2.5", optional = true }
http = { version = "0.2.7", optional = true }
regex = "1.5"
serde = "1"
tracing = { version = "0.1.30", default-features = false, features = ["log"] }
[dev-dependencies]
criterion = { version = "0.4", features = ["html_reports"] }
http = "0.2.5"
http = "0.2.7"
serde = { version = "1", features = ["derive"] }
percent-encoding = "2.1"

View File

@ -5,6 +5,7 @@
#![allow(clippy::uninlined_format_args)]
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
mod de;
mod path;

View File

@ -1,7 +1,10 @@
# Changes
## Unreleased - 2022-xx-xx
## Unreleased - 2023-xx-xx
## 0.1.1 - 2023-02-26
- Add `TestServerConfig::port()` setter method.
- Minimum supported Rust version (MSRV) is now 1.59 due to transitive `time` dependency.
## 0.1.0 - 2022-07-24

View File

@ -1,6 +1,6 @@
[package]
name = "actix-test"
version = "0.1.0"
version = "0.1.1"
authors = [
"Nikolay Kim <fafhrd91@gmail.com>",
"Rob Ede <robjtede@icloud.com>",
@ -45,4 +45,4 @@ serde_json = "1"
serde_urlencoded = "0.7"
tls-openssl = { package = "openssl", version = "0.10.9", optional = true }
tls-rustls = { package = "rustls", version = "0.20.0", optional = true }
tokio = { version = "1.18.5", features = ["sync"] }
tokio = { version = "1.24.2", features = ["sync"] }

View File

@ -28,6 +28,9 @@
#![deny(rust_2018_idioms, nonstandard_style)]
#![warn(future_incompatible)]
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#[cfg(feature = "openssl")]
extern crate tls_openssl as openssl;
@ -145,7 +148,7 @@ where
// run server in separate orphaned thread
thread::spawn(move || {
rt::System::new().block_on(async move {
let tcp = net::TcpListener::bind("127.0.0.1:0").unwrap();
let tcp = net::TcpListener::bind(("127.0.0.1", cfg.port)).unwrap();
let local_addr = tcp.local_addr().unwrap();
let factory = factory.clone();
let srv_cfg = cfg.clone();
@ -390,6 +393,7 @@ pub struct TestServerConfig {
tp: HttpVer,
stream: StreamType,
client_request_timeout: Duration,
port: u16,
}
impl Default for TestServerConfig {
@ -405,6 +409,7 @@ impl TestServerConfig {
tp: HttpVer::Both,
stream: StreamType::Tcp,
client_request_timeout: Duration::from_secs(5),
port: 0,
}
}
@ -439,6 +444,14 @@ impl TestServerConfig {
self.client_request_timeout = dur;
self
}
/// Sets test server port.
///
/// By default, a random free port is determined by the OS.
pub fn port(mut self, port: u16) -> Self {
self.port = port;
self
}
}
/// A basic HTTP server controller that simplifies the process of writing integration tests for

View File

@ -1,6 +1,6 @@
# Changes
## Unreleased - 2022-xx-xx
## Unreleased - 2023-xx-xx
## 4.2.0 - 2023-01-21

View File

@ -23,7 +23,7 @@ bytes = "1"
bytestring = "1"
futures-core = { version = "0.3.17", default-features = false }
pin-project-lite = "0.2"
tokio = { version = "1.18.5", features = ["sync"] }
tokio = { version = "1.24.2", features = ["sync"] }
tokio-util = { version = "0.7", features = ["codec"] }
[dev-dependencies]

View File

@ -58,6 +58,9 @@
#![deny(rust_2018_idioms, nonstandard_style)]
#![warn(future_incompatible)]
#![allow(clippy::uninlined_format_args)]
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
mod context;
pub mod ws;

View File

@ -1,10 +1,10 @@
# Changes
## Unreleased - 2022-xx-xx
## Unreleased - 2023-xx-xx
## 4.2.0 - 2023-02-26
- Add support for Custom Methods with `#[route]` macro. [#2969]
- Add support for custom methods with the `#[route]` macro. [#2969]
[#2969]: https://github.com/actix/actix-web/pull/2969

View File

@ -75,6 +75,9 @@
#![recursion_limit = "512"]
#![deny(rust_2018_idioms, nonstandard_style)]
#![warn(future_incompatible)]
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
use proc_macro::TokenStream;
use quote::quote;

View File

@ -1,6 +1,10 @@
# Changelog
## Unreleased - 2022-xx-xx
## Unreleased - 2023-xx-xx
- Add `Resource::{get, post, etc...}` methods for more concisely adding routes that don't need additional guards.
## 4.3.1 - 2023-02-26
- Add support for custom methods with the `#[route]` macro. [#2969]

View File

@ -1,6 +1,6 @@
[package]
name = "actix-web"
version = "4.3.0"
version = "4.3.1"
authors = [
"Nikolay Kim <fafhrd91@gmail.com>",
"Rob Ede <robjtede@icloud.com>",
@ -72,7 +72,7 @@ actix-http = { version = "3.3", features = ["http2", "ws"] }
actix-router = "0.5"
actix-web-codegen = { version = "4.2", optional = true }
ahash = "0.7"
ahash = "0.8"
bytes = "1"
bytestring = "1"
cfg-if = "1"
@ -81,7 +81,6 @@ derive_more = "0.99.8"
encoding_rs = "0.8"
futures-core = { version = "0.3.17", default-features = false }
futures-util = { version = "0.3.17", default-features = false }
http = "0.2.8"
itoa = "1"
language-tags = "0.3"
log = "0.4"
@ -93,7 +92,7 @@ serde = "1.0"
serde_json = "1.0"
serde_urlencoded = "0.7"
smallvec = "1.6.1"
socket2 = "0.4.0"
socket2 = "0.4"
time = { version = "0.3", default-features = false, features = ["formatting"] }
url = "2.1"
@ -115,7 +114,7 @@ serde = { version = "1.0", features = ["derive"] }
static_assertions = "1"
tls-openssl = { package = "openssl", version = "0.10.9" }
tls-rustls = { package = "rustls", version = "0.20.0" }
tokio = { version = "1.18.5", features = ["rt-multi-thread", "macros"] }
tokio = { version = "1.24.2", features = ["rt-multi-thread", "macros"] }
zstd = "0.12"
[[test]]

View File

@ -5,7 +5,7 @@
</p>
<p>
[![crates.io](https://img.shields.io/crates/v/actix-web?label=latest)](https://crates.io/crates/actix-web) [![Documentation](https://docs.rs/actix-web/badge.svg?version=4.3.0)](https://docs.rs/actix-web/4.3.0) ![MSRV](https://img.shields.io/badge/rustc-1.59+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-web.svg) [![Dependency Status](https://deps.rs/crate/actix-web/4.3.0/status.svg)](https://deps.rs/crate/actix-web/4.3.0) <br /> [![CI](https://github.com/actix/actix-web/actions/workflows/ci.yml/badge.svg)](https://github.com/actix/actix-web/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/actix/actix-web/branch/master/graph/badge.svg)](https://codecov.io/gh/actix/actix-web) ![downloads](https://img.shields.io/crates/d/actix-web.svg) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x)
[![crates.io](https://img.shields.io/crates/v/actix-web?label=latest)](https://crates.io/crates/actix-web) [![Documentation](https://docs.rs/actix-web/badge.svg?version=4.3.1)](https://docs.rs/actix-web/4.3.1) ![MSRV](https://img.shields.io/badge/rustc-1.59+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-web.svg) [![Dependency Status](https://deps.rs/crate/actix-web/4.3.1/status.svg)](https://deps.rs/crate/actix-web/4.3.1) <br /> [![CI](https://github.com/actix/actix-web/actions/workflows/ci.yml/badge.svg)](https://github.com/actix/actix-web/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/actix/actix-web/branch/master/graph/badge.svg)](https://codecov.io/gh/actix/actix-web) ![downloads](https://img.shields.io/crates/d/actix-web.svg) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x)
</p>
</div>

View File

@ -72,7 +72,7 @@
#![allow(clippy::uninlined_format_args)]
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
mod app;
mod app_service;
@ -119,14 +119,12 @@ pub use crate::types::Either;
pub use actix_http::{body, HttpMessage};
#[cfg(feature = "cookies")]
#[cfg_attr(docsrs, doc(cfg(feature = "cookies")))]
#[doc(inline)]
pub use cookie;
macro_rules! codegen_reexport {
($name:ident) => {
#[cfg(feature = "macros")]
#[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
pub use actix_web_codegen::$name;
};
}

View File

@ -50,18 +50,24 @@ type DefaultHandler<B> = Option<Rc<ErrorHandler<B>>>;
/// will pass by unchanged by this middleware.
///
/// # Examples
/// ## Handler Response
/// Header
/// ```
/// use actix_web::http::{header, StatusCode};
/// use actix_web::middleware::{ErrorHandlerResponse, ErrorHandlers};
/// use actix_web::{dev, web, App, HttpResponse, Result};
///
/// fn add_error_header<B>(mut res: dev::ServiceResponse<B>) -> Result<ErrorHandlerResponse<B>> {
/// Adding a header:
///
/// ```
/// use actix_web::{
/// dev::ServiceResponse,
/// http::{header, StatusCode},
/// middleware::{ErrorHandlerResponse, ErrorHandlers},
/// web, App, HttpResponse, Result,
/// };
///
/// fn add_error_header<B>(mut res: ServiceResponse<B>) -> Result<ErrorHandlerResponse<B>> {
/// res.response_mut().headers_mut().insert(
/// header::CONTENT_TYPE,
/// header::HeaderValue::from_static("Error"),
/// );
///
/// // body is unchanged, map to "left" slot
/// Ok(ErrorHandlerResponse::Response(res.map_into_left_body()))
/// }
///
@ -70,45 +76,62 @@ type DefaultHandler<B> = Option<Rc<ErrorHandler<B>>>;
/// .service(web::resource("/").route(web::get().to(HttpResponse::InternalServerError)));
/// ```
///
/// Body Content
/// Modifying response body:
///
/// ```
/// use actix_web::http::{header, StatusCode};
/// use actix_web::middleware::{ErrorHandlerResponse, ErrorHandlers};
/// use actix_web::{dev, web, App, HttpResponse, Result};
/// fn add_error_body<B>(res: dev::ServiceResponse<B>) -> Result<ErrorHandlerResponse<B>> {
/// // Get the error message and status code
/// let error_message = "An error occurred";
/// // Destructures ServiceResponse into request and response components
/// let (req, res) = res.into_parts();
/// // Create a new response with the modified body
/// let res = res.set_body(error_message).map_into_boxed_body();
/// // Create a new ServiceResponse with the modified response
/// let res = dev::ServiceResponse::new(req, res).map_into_right_body();
/// Ok(ErrorHandlerResponse::Response(res))
///}
/// use actix_web::{
/// dev::ServiceResponse,
/// http::{header, StatusCode},
/// middleware::{ErrorHandlerResponse, ErrorHandlers},
/// web, App, HttpResponse, Result,
/// };
///
/// fn add_error_body<B>(res: ServiceResponse<B>) -> Result<ErrorHandlerResponse<B>> {
/// // split service response into request and response components
/// let (req, res) = res.into_parts();
///
/// // set body of response to modified body
/// let res = res.set_body("An error occurred.");
///
/// // modified bodies need to be boxed and placed in the "right" slot
/// let res = ServiceResponse::new(req, res)
/// .map_into_boxed_body()
/// .map_into_right_body();
///
/// Ok(ErrorHandlerResponse::Response(res))
/// }
///
/// let app = App::new()
/// .wrap(ErrorHandlers::new().handler(StatusCode::INTERNAL_SERVER_ERROR, add_error_body))
/// .service(web::resource("/").route(web::get().to(HttpResponse::InternalServerError)));
/// ```
/// ## Registering default handler
///
/// Registering default handler:
///
/// ```
/// # use actix_web::http::{header, StatusCode};
/// # use actix_web::middleware::{ErrorHandlerResponse, ErrorHandlers};
/// # use actix_web::{dev, web, App, HttpResponse, Result};
/// fn add_error_header<B>(mut res: dev::ServiceResponse<B>) -> Result<ErrorHandlerResponse<B>> {
/// # use actix_web::{
/// # dev::ServiceResponse,
/// # http::{header, StatusCode},
/// # middleware::{ErrorHandlerResponse, ErrorHandlers},
/// # web, App, HttpResponse, Result,
/// # };
/// fn add_error_header<B>(mut res: ServiceResponse<B>) -> Result<ErrorHandlerResponse<B>> {
/// res.response_mut().headers_mut().insert(
/// header::CONTENT_TYPE,
/// header::HeaderValue::from_static("Error"),
/// );
///
/// // body is unchanged, map to "left" slot
/// Ok(ErrorHandlerResponse::Response(res.map_into_left_body()))
/// }
///
/// fn handle_bad_request<B>(mut res: dev::ServiceResponse<B>) -> Result<ErrorHandlerResponse<B>> {
/// fn handle_bad_request<B>(mut res: ServiceResponse<B>) -> Result<ErrorHandlerResponse<B>> {
/// res.response_mut().headers_mut().insert(
/// header::CONTENT_TYPE,
/// header::HeaderValue::from_static("Bad Request Error"),
/// );
///
/// // body is unchanged, map to "left" slot
/// Ok(ErrorHandlerResponse::Response(res.map_into_left_body()))
/// }
///
@ -122,20 +145,24 @@ type DefaultHandler<B> = Option<Rc<ErrorHandler<B>>>;
/// )
/// .service(web::resource("/").route(web::get().to(HttpResponse::InternalServerError)));
/// ```
/// Alternatively, you can set default handlers for only client or only server errors:
///
/// ```rust
/// # use actix_web::http::{header, StatusCode};
/// # use actix_web::middleware::{ErrorHandlerResponse, ErrorHandlers};
/// # use actix_web::{dev, web, App, HttpResponse, Result};
/// # fn add_error_header<B>(mut res: dev::ServiceResponse<B>) -> Result<ErrorHandlerResponse<B>> {
/// You can set default handlers for all client (4xx) or all server (5xx) errors:
///
/// ```
/// # use actix_web::{
/// # dev::ServiceResponse,
/// # http::{header, StatusCode},
/// # middleware::{ErrorHandlerResponse, ErrorHandlers},
/// # web, App, HttpResponse, Result,
/// # };
/// # fn add_error_header<B>(mut res: ServiceResponse<B>) -> Result<ErrorHandlerResponse<B>> {
/// # res.response_mut().headers_mut().insert(
/// # header::CONTENT_TYPE,
/// # header::HeaderValue::from_static("Error"),
/// # );
/// # Ok(ErrorHandlerResponse::Response(res.map_into_left_body()))
/// # }
/// # fn handle_bad_request<B>(mut res: dev::ServiceResponse<B>) -> Result<ErrorHandlerResponse<B>> {
/// # fn handle_bad_request<B>(mut res: ServiceResponse<B>) -> Result<ErrorHandlerResponse<B>> {
/// # res.response_mut().headers_mut().insert(
/// # header::CONTENT_TYPE,
/// # header::HeaderValue::from_static("Bad Request Error"),

View File

@ -311,7 +311,6 @@ impl HttpRequest {
/// Load request cookies.
#[cfg(feature = "cookies")]
#[cfg_attr(docsrs, doc(cfg(feature = "cookies")))]
pub fn cookies(&self) -> Result<Ref<'_, Vec<Cookie<'static>>>, CookieParseError> {
use actix_http::header::COOKIE;
@ -335,7 +334,6 @@ impl HttpRequest {
/// Return request cookie.
#[cfg(feature = "cookies")]
#[cfg_attr(docsrs, doc(cfg(feature = "cookies")))]
pub fn cookie(&self, name: &str) -> Option<Cookie<'static>> {
if let Ok(cookies) = self.cookies() {
for cookie in cookies.iter() {

View File

@ -21,7 +21,7 @@ use crate::{
BoxedHttpService, BoxedHttpServiceFactory, HttpServiceFactory, ServiceRequest,
ServiceResponse,
},
Error, FromRequest, HttpResponse, Responder,
web, Error, FromRequest, HttpResponse, Responder,
};
/// A collection of [`Route`]s that respond to the same path pattern.
@ -38,11 +38,13 @@ use crate::{
///
/// let app = App::new().service(
/// web::resource("/")
/// .route(web::get().to(|| HttpResponse::Ok())));
/// .get(|| HttpResponse::Ok())
/// .post(|| async { "Hello World!" })
/// );
/// ```
///
/// If no matching route is found, [a 405 response is returned with an appropriate Allow header][RFC
/// 9110 §15.5.6]. This default behavior can be overridden using
/// If no matching route is found, an empty 405 response is returned which includes an
/// [appropriate Allow header][RFC 9110 §15.5.6]. This default behavior can be overridden using
/// [`default_service()`](Self::default_service).
///
/// [RFC 9110 §15.5.6]: https://www.rfc-editor.org/rfc/rfc9110.html#section-15.5.6
@ -58,6 +60,7 @@ pub struct Resource<T = ResourceEndpoint> {
}
impl Resource {
/// Constructs new resource that matches a `path` pattern.
pub fn new<T: IntoPatterns>(path: T) -> Resource {
let fref = Rc::new(RefCell::new(None));
@ -368,6 +371,45 @@ where
}
}
macro_rules! route_shortcut {
($method_fn:ident, $method_upper:literal) => {
#[doc = concat!(" Adds a ", $method_upper, " route.")]
///
/// Use [`route`](Self::route) if you need to add additional guards.
///
/// # Examples
///
/// ```
/// # use actix_web::web;
/// web::resource("/")
#[doc = concat!(" .", stringify!($method_fn), "(|| async { \"Hello World!\" })")]
/// # ;
/// ```
pub fn $method_fn<F, Args>(self, handler: F) -> Self
where
F: Handler<Args>,
Args: FromRequest + 'static,
F::Output: Responder + 'static,
{
self.route(web::$method_fn().to(handler))
}
};
}
/// Concise routes for well-known HTTP methods.
impl<T> Resource<T>
where
T: ServiceFactory<ServiceRequest, Config = (), Error = Error, InitError = ()>,
{
route_shortcut!(get, "GET");
route_shortcut!(post, "POST");
route_shortcut!(put, "PUT");
route_shortcut!(patch, "PATCH");
route_shortcut!(delete, "DELETE");
route_shortcut!(head, "HEAD");
route_shortcut!(trace, "TRACE");
}
impl<T, B> HttpServiceFactory for Resource<T>
where
T: ServiceFactory<

View File

@ -217,7 +217,6 @@ where
///
/// By default handshake timeout is set to 3000 milliseconds.
#[cfg(any(feature = "openssl", feature = "rustls"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "openssl", feature = "rustls"))))]
pub fn tls_handshake_timeout(self, dur: Duration) -> Self {
self.config
.lock()
@ -382,7 +381,6 @@ where
///
/// ALPN protocols "h2" and "http/1.1" are added to any configured ones.
#[cfg(feature = "rustls")]
#[cfg_attr(docsrs, doc(cfg(feature = "rustls")))]
pub fn bind_rustls<A: net::ToSocketAddrs>(
mut self,
addrs: A,
@ -402,7 +400,6 @@ where
///
/// ALPN protocols "h2" and "http/1.1" are added to any configured ones.
#[cfg(feature = "openssl")]
#[cfg_attr(docsrs, doc(cfg(feature = "openssl")))]
pub fn bind_openssl<A>(mut self, addrs: A, builder: SslAcceptorBuilder) -> io::Result<Self>
where
A: net::ToSocketAddrs,
@ -469,7 +466,6 @@ where
///
/// ALPN protocols "h2" and "http/1.1" are added to any configured ones.
#[cfg(feature = "rustls")]
#[cfg_attr(docsrs, doc(cfg(feature = "rustls")))]
pub fn listen_rustls(
self,
lst: net::TcpListener,
@ -535,7 +531,6 @@ where
///
/// ALPN protocols "h2" and "http/1.1" are added to any configured ones.
#[cfg(feature = "openssl")]
#[cfg_attr(docsrs, doc(cfg(feature = "openssl")))]
pub fn listen_openssl(
self,
lst: net::TcpListener,

View File

@ -62,7 +62,6 @@ actix-rt = { version = "2.1", default-features = false }
actix-tls = { version = "3", features = ["connect", "uri"] }
actix-utils = "3"
ahash = "0.7"
base64 = "0.21"
bytes = "1"
cfg-if = "1"
@ -70,7 +69,7 @@ derive_more = "0.99.5"
futures-core = { version = "0.3.17", default-features = false, features = ["alloc"] }
futures-util = { version = "0.3.17", default-features = false, features = ["alloc", "sink"] }
h2 = "0.3.9"
http = "0.2.5"
http = "0.2.7"
itoa = "1"
log =" 0.4"
mime = "0.3"
@ -80,7 +79,7 @@ rand = "0.8"
serde = "1.0"
serde_json = "1.0"
serde_urlencoded = "0.7"
tokio = { version = "1.18.5", features = ["sync"] }
tokio = { version = "1.24.2", features = ["sync"] }
cookie = { version = "0.16", features = ["percent-encode"], optional = true }
@ -106,7 +105,7 @@ futures-util = { version = "0.3.17", default-features = false }
static_assertions = "1.1"
rcgen = "0.9"
rustls-pemfile = "1"
tokio = { version = "1.18.5", features = ["rt-multi-thread", "macros"] }
tokio = { version = "1.24.2", features = ["rt-multi-thread", "macros"] }
zstd = "0.12"
[[example]]

View File

@ -2,7 +2,7 @@
use std::{
cell::RefCell,
collections::VecDeque,
collections::{HashMap, VecDeque},
future::Future,
io,
ops::Deref,
@ -17,7 +17,6 @@ use actix_codec::{AsyncRead, AsyncWrite, ReadBuf};
use actix_http::Protocol;
use actix_rt::time::{sleep, Sleep};
use actix_service::Service;
use ahash::AHashMap;
use futures_core::future::LocalBoxFuture;
use futures_util::FutureExt as _;
use http::uri::Authority;
@ -62,7 +61,7 @@ where
{
fn new(config: ConnectorConfig) -> Self {
let permits = Arc::new(Semaphore::new(config.limit));
let available = RefCell::new(AHashMap::default());
let available = RefCell::new(HashMap::default());
Self(Rc::new(ConnectionPoolInnerPriv {
config,
@ -124,7 +123,7 @@ where
Io: AsyncWrite + Unpin + 'static,
{
config: ConnectorConfig,
available: RefCell<AHashMap<Key, VecDeque<PooledConnection<Io>>>>,
available: RefCell<HashMap<Key, VecDeque<PooledConnection<Io>>>>,
permits: Arc<Semaphore>,
}

View File

@ -110,6 +110,7 @@
)]
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
pub use actix_http::body;