mirror of https://github.com/fafhrd91/actix-web
Compare commits
17 Commits
9b80b3f9f1
...
21dea2809f
Author | SHA1 | Date |
---|---|---|
|
21dea2809f | |
|
b6ad483699 | |
|
c002fd783c | |
|
95ad1caa23 | |
|
eb906d077a | |
|
f08fa6b684 | |
|
98e0cc4049 | |
|
cfaa5b24c7 | |
|
66873d16b5 | |
|
4f8819d277 | |
|
f96a21f1fa | |
|
b66866d2d1 | |
|
bbb7258e7b | |
|
3ff861eb29 | |
|
f5d340878c | |
|
342242a0e7 | |
|
9b6a93d72c |
|
@ -49,7 +49,7 @@ jobs:
|
|||
toolchain: ${{ matrix.version.version }}
|
||||
|
||||
- name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean
|
||||
uses: taiki-e/install-action@v2.54.3
|
||||
uses: taiki-e/install-action@v2.56.13
|
||||
with:
|
||||
tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean
|
||||
|
||||
|
@ -83,7 +83,7 @@ jobs:
|
|||
uses: actions-rust-lang/setup-rust-toolchain@v1.13.0
|
||||
|
||||
- name: Install just, cargo-hack
|
||||
uses: taiki-e/install-action@v2.54.3
|
||||
uses: taiki-e/install-action@v2.56.13
|
||||
with:
|
||||
tool: just,cargo-hack
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ jobs:
|
|||
toolchain: ${{ matrix.version.version }}
|
||||
|
||||
- name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean
|
||||
uses: taiki-e/install-action@v2.54.3
|
||||
uses: taiki-e/install-action@v2.56.13
|
||||
with:
|
||||
tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean
|
||||
|
||||
|
@ -113,7 +113,7 @@ jobs:
|
|||
toolchain: nightly
|
||||
|
||||
- name: Install just
|
||||
uses: taiki-e/install-action@v2.54.3
|
||||
uses: taiki-e/install-action@v2.56.13
|
||||
with:
|
||||
tool: just
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ jobs:
|
|||
components: llvm-tools
|
||||
|
||||
- name: Install just, cargo-llvm-cov, cargo-nextest
|
||||
uses: taiki-e/install-action@v2.54.3
|
||||
uses: taiki-e/install-action@v2.56.13
|
||||
with:
|
||||
tool: just,cargo-llvm-cov,cargo-nextest
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ jobs:
|
|||
toolchain: ${{ vars.RUST_VERSION_EXTERNAL_TYPES }}
|
||||
|
||||
- name: Install just
|
||||
uses: taiki-e/install-action@v2.54.3
|
||||
uses: taiki-e/install-action@v2.56.13
|
||||
with:
|
||||
tool: just
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ dependencies = [
|
|||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
"slab",
|
||||
"socket2 0.5.10",
|
||||
"socket2 0.6.0",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
|
@ -393,7 +393,7 @@ dependencies = [
|
|||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
"smallvec",
|
||||
"socket2 0.5.10",
|
||||
"socket2 0.6.0",
|
||||
"static_assertions",
|
||||
"time",
|
||||
"tokio",
|
||||
|
@ -1509,9 +1509,9 @@ checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2"
|
|||
|
||||
[[package]]
|
||||
name = "h2"
|
||||
version = "0.3.26"
|
||||
version = "0.3.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8"
|
||||
checksum = "0beca50380b1fc32983fc1cb4587bfa4bb9e78fc259aad4a0032d2080309222d"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"fnv",
|
||||
|
@ -1785,6 +1785,17 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "io-uring"
|
||||
version = "0.7.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b86e202f00093dcba4275d4636b93ef9dd75d025ae560d2521b45ea28ab49013"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ipconfig"
|
||||
version = "0.3.2"
|
||||
|
@ -2794,9 +2805,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_spanned"
|
||||
version = "0.6.8"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1"
|
||||
checksum = "40734c41988f7306bb04f0ecf60ec0f3f1caa34290e4e8ea471dcd3346483b83"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
@ -2882,6 +2893,16 @@ dependencies = [
|
|||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.5.2"
|
||||
|
@ -3066,17 +3087,19 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
|||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.45.1"
|
||||
version = "1.46.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75ef51a33ef1da925cea3e4eb122833cb377c61439ca401b770f54902b806779"
|
||||
checksum = "0cc3a2344dafbe23a245241fe8b09735b521110d30fcefbbd5feb1797ca35d17"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"bytes",
|
||||
"io-uring 0.7.8",
|
||||
"libc",
|
||||
"mio",
|
||||
"parking_lot",
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"slab",
|
||||
"socket2 0.5.10",
|
||||
"tokio-macros",
|
||||
"windows-sys 0.52.0",
|
||||
|
@ -3165,7 +3188,7 @@ checksum = "748482e3e13584a34664a710168ad5068e8cb1d968aa4ffa887e83ca6dd27967"
|
|||
dependencies = [
|
||||
"bytes",
|
||||
"futures-util",
|
||||
"io-uring",
|
||||
"io-uring 0.6.4",
|
||||
"libc",
|
||||
"slab",
|
||||
"socket2 0.4.10",
|
||||
|
@ -3187,44 +3210,42 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.8.22"
|
||||
version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05ae329d1f08c4d17a59bed7ff5b5a769d062e64a62d34a3261b219e62cd5aae"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"toml_edit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "0.6.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3da5db5a963e24bc68be8b17b6fa82814bb22ee8660f192bb182771d498f09a3"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.22.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "310068873db2c5b3e7659d2cc35d21855dbafa50d1ce336397c666e3cb08137e"
|
||||
checksum = "ed0aee96c12fa71097902e0bb061a5e1ebd766a6636bb605ba401c45c1650eac"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"toml_write",
|
||||
"toml_parser",
|
||||
"toml_writer",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_write"
|
||||
version = "0.1.1"
|
||||
name = "toml_datetime"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bfb942dfe1d8e29a7ee7fcbde5bd2b9a25fb89aa70caea2eba3bee836ff41076"
|
||||
checksum = "bade1c3e902f58d73d3f294cd7f20391c1cb2fbcb643b73566bc773971df91e3"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_parser"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97200572db069e74c512a14117b296ba0a80a30123fbbb5aa1f4a348f639ca30"
|
||||
dependencies = [
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_writer"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fcc842091f2def52017664b53082ecbbeb5c7731092bad69d2c63050401dfd64"
|
||||
|
||||
[[package]]
|
||||
name = "tracing"
|
||||
|
@ -3306,9 +3327,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "trybuild"
|
||||
version = "1.0.105"
|
||||
version = "1.0.106"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1c9bf9513a2f4aeef5fdac8677d7d349c79fdbcc03b9c86da6e9d254f1e43be2"
|
||||
checksum = "65af40ad689f2527aebbd37a0a816aea88ff5f774ceabe99de5be02f2f91dae2"
|
||||
dependencies = [
|
||||
"glob",
|
||||
"serde",
|
||||
|
@ -3759,9 +3780,6 @@ name = "winnow"
|
|||
version = "0.7.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c06928c8748d81b05c9be96aad92e1b6ff01833332f281e8cfca3be4b35fc9ec"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winreg"
|
||||
|
|
|
@ -53,7 +53,7 @@ serde = "1"
|
|||
serde_json = "1"
|
||||
serde_urlencoded = "0.7"
|
||||
slab = "0.4"
|
||||
socket2 = "0.5"
|
||||
socket2 = "0.6"
|
||||
tls-openssl = { version = "0.10.55", package = "openssl", optional = true }
|
||||
tokio = { version = "1.38.2", features = ["sync"] }
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! [`TryIntoHeaderValue`] trait and implementations.
|
||||
|
||||
use bytes::Bytes;
|
||||
use http::{header::InvalidHeaderValue, Error as HttpError, HeaderValue};
|
||||
use http::{header::InvalidHeaderValue, Error as HttpError, HeaderValue, Uri};
|
||||
use mime::Mime;
|
||||
|
||||
/// An interface for types that can be converted into a [`HeaderValue`].
|
||||
|
@ -129,3 +129,12 @@ impl TryIntoHeaderValue for Mime {
|
|||
HeaderValue::from_str(self.as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
impl TryIntoHeaderValue for Uri {
|
||||
type Error = InvalidHeaderValue;
|
||||
|
||||
#[inline]
|
||||
fn try_into_value(self) -> Result<HeaderValue, Self::Error> {
|
||||
HeaderValue::from_str(&self.to_string())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,10 @@
|
|||
- On Windows, an error is now returned from `HttpServer::bind()` (or TLS variants) when binding to a socket that's already in use.
|
||||
- Update `brotli` dependency to `7`.
|
||||
- Minimum supported Rust version (MSRV) is now 1.75.
|
||||
- Add `TryIntoHeaderValue` for `Uri` type.
|
||||
- Add `http::header::ContentLocation` typed header.
|
||||
- Add `http::header::Location` typed header.
|
||||
- Add `http::header::Referer` typed header.
|
||||
|
||||
## 4.9.0
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ serde = "1.0"
|
|||
serde_json = "1.0"
|
||||
serde_urlencoded = "0.7"
|
||||
smallvec = "1.6.1"
|
||||
socket2 = "0.5"
|
||||
socket2 = "0.6"
|
||||
time = { version = "0.3", default-features = false, features = ["formatting"] }
|
||||
tracing = "0.1.30"
|
||||
url = "2.5.4"
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
use super::{Uri, CONTENT_LOCATION};
|
||||
|
||||
crate::http::header::common_header! {
|
||||
/// `Content-Location` header, defined
|
||||
/// in [RFC 9110 §8.7](https://datatracker.ietf.org/doc/html/rfc9110#section-8.7)
|
||||
///
|
||||
/// The "Content-Location" header field references a URI that can be used
|
||||
/// as an identifier for a specific resource corresponding to the
|
||||
/// representation in this message's content.
|
||||
///
|
||||
/// # ABNF
|
||||
/// ```plain
|
||||
/// Content-Location = absolute-URI / partial-URI
|
||||
/// ```
|
||||
///
|
||||
/// # Example Values
|
||||
/// * `http://www.example.org/hypertext/Overview.html`
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use actix_web::HttpResponse;
|
||||
/// use actix_http::Uri;
|
||||
/// use actix_web::http::header::ContentLocation;
|
||||
///
|
||||
/// let mut builder = HttpResponse::Created();
|
||||
/// builder.insert_header(
|
||||
/// ContentLocation("http://www.example.org".parse::<Uri>().unwrap())
|
||||
/// );
|
||||
/// ```
|
||||
(ContentLocation, CONTENT_LOCATION) => [Uri]
|
||||
|
||||
test_parse_and_format {
|
||||
crate::http::header::common_header_test!(test1, [b"http://www.example.org/hypertext/Overview.html"]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
use super::{Uri, LOCATION};
|
||||
|
||||
crate::http::header::common_header! {
|
||||
/// `Location` header, defined
|
||||
/// in [RFC 9110 §10.2.2](https://datatracker.ietf.org/doc/html/rfc9110#section-10.2.2)
|
||||
///
|
||||
/// The "Location" header field is used in some responses to refer to a
|
||||
/// specific resource in relation to the response. The type of relationship
|
||||
/// is defined by the combination of request method and status code
|
||||
/// semantics.
|
||||
///
|
||||
/// # ABNF
|
||||
/// ```plain
|
||||
/// Location = URI-reference
|
||||
/// ```
|
||||
///
|
||||
/// # Example Values
|
||||
/// * `http://www.example.org/hypertext/Overview.html`
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use actix_web::HttpResponse;
|
||||
/// use actix_http::Uri;
|
||||
/// use actix_web::http::header::Location;
|
||||
///
|
||||
/// let mut builder = HttpResponse::Ok();
|
||||
/// builder.insert_header(
|
||||
/// Location("http://www.example.org".parse::<Uri>().unwrap())
|
||||
/// );
|
||||
/// ```
|
||||
(Location, LOCATION) => [Uri]
|
||||
|
||||
test_parse_and_format {
|
||||
crate::http::header::common_header_test!(test1, [b"http://www.example.org/hypertext/Overview.html"]);
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ use std::fmt;
|
|||
// - the few typed headers from actix-http
|
||||
// - header parsing utils
|
||||
pub use actix_http::header::*;
|
||||
use actix_http::Uri;
|
||||
use bytes::{Bytes, BytesMut};
|
||||
|
||||
mod accept;
|
||||
|
@ -25,6 +26,7 @@ mod cache_control;
|
|||
mod content_disposition;
|
||||
mod content_language;
|
||||
mod content_length;
|
||||
mod content_location;
|
||||
mod content_range;
|
||||
mod content_type;
|
||||
mod date;
|
||||
|
@ -38,9 +40,11 @@ mod if_none_match;
|
|||
mod if_range;
|
||||
mod if_unmodified_since;
|
||||
mod last_modified;
|
||||
mod location;
|
||||
mod macros;
|
||||
mod preference;
|
||||
mod range;
|
||||
mod referer;
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) use self::macros::common_header_test;
|
||||
|
@ -55,6 +59,7 @@ pub use self::{
|
|||
content_disposition::{ContentDisposition, DispositionParam, DispositionType},
|
||||
content_language::ContentLanguage,
|
||||
content_length::ContentLength,
|
||||
content_location::ContentLocation,
|
||||
content_range::{ContentRange, ContentRangeSpec},
|
||||
content_type::ContentType,
|
||||
date::Date,
|
||||
|
@ -68,8 +73,10 @@ pub use self::{
|
|||
if_range::IfRange,
|
||||
if_unmodified_since::IfUnmodifiedSince,
|
||||
last_modified::LastModified,
|
||||
location::Location,
|
||||
preference::Preference,
|
||||
range::{ByteRangeSpec, Range},
|
||||
referer::Referer,
|
||||
};
|
||||
|
||||
/// Format writer ([`fmt::Write`]) for a [`BytesMut`].
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
use super::{Uri, REFERER};
|
||||
|
||||
crate::http::header::common_header! {
|
||||
/// `Referer` header, defined
|
||||
/// in [RFC 9110 §10.1.3](https://datatracker.ietf.org/doc/html/rfc9110#section-10.1.3)
|
||||
///
|
||||
/// The "Referer" (sic) header field allows the user agent to specify a URI
|
||||
/// reference for the resource from which the target URI was obtained (i.e.,
|
||||
/// the "referrer", though the field name is misspelled).
|
||||
///
|
||||
/// # ABNF
|
||||
/// ```plain
|
||||
/// Referer = absolute-URI / partial-URI
|
||||
/// ```
|
||||
///
|
||||
/// # Example Values
|
||||
/// * `http://www.example.org/hypertext/Overview.html`
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use actix_web::HttpResponse;
|
||||
/// use actix_http::Uri;
|
||||
/// use actix_web::http::header::Referer;
|
||||
///
|
||||
/// let mut builder = HttpResponse::Ok();
|
||||
/// builder.insert_header(
|
||||
/// Referer("http://www.example.org".parse::<Uri>().unwrap())
|
||||
/// );
|
||||
/// ```
|
||||
(Referer, REFERER) => [Uri]
|
||||
|
||||
test_parse_and_format {
|
||||
crate::http::header::common_header_test!(test1, [b"http://www.example.org/hypertext/Overview.html"]);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue