Compare commits

...

13 Commits

Author SHA1 Message Date
Keith Cirkel ef09852b01
Merge 98e0cc4049 into c85e058f5d 2025-08-31 23:11:06 -07:00
dependabot[bot] c85e058f5d
build(deps): bump rui314/setup-mold from 7344740a9418dcdcb481c7df83d9fbd1d5072d7d to 725a8794d15fc7563f59595bd9556495c0564878 (#3752)
build(deps): bump rui314/setup-mold

Bumps [rui314/setup-mold](https://github.com/rui314/setup-mold) from 7344740a9418dcdcb481c7df83d9fbd1d5072d7d to 725a8794d15fc7563f59595bd9556495c0564878.
- [Commits](7344740a94...725a8794d1)

---
updated-dependencies:
- dependency-name: rui314/setup-mold
  dependency-version: 725a8794d15fc7563f59595bd9556495c0564878
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-09-01 01:54:18 +00:00
Rob Ede 98e0cc4049
Merge branch 'master' into add-uri-typed-headers 2025-05-10 21:17:56 +01:00
Rob Ede cfaa5b24c7
Merge branch 'master' into add-uri-typed-headers 2024-10-01 05:19:11 +01:00
Keith Cirkel 66873d16b5
Merge branch 'master' into add-uri-typed-headers 2024-09-17 09:55:44 +01:00
Keith Cirkel 4f8819d277
use parens to appease linter 2024-08-21 00:18:09 +01:00
Keith Cirkel f96a21f1fa
make Uri in http::header private 2024-08-19 14:13:00 +01:00
Keith Cirkel b66866d2d1
update references and text to RFC 9110 2024-08-19 14:13:00 +01:00
Keith Cirkel bbb7258e7b
add changelog entry for TryIntoHeaderValue Uri 2024-08-19 14:12:58 +01:00
Keith Cirkel 3ff861eb29
add referer typed header 2024-08-19 14:12:39 +01:00
Keith Cirkel f5d340878c
add location typed header 2024-08-19 14:12:39 +01:00
Keith Cirkel 342242a0e7
add content-location typed header 2024-08-19 14:12:38 +01:00
Keith Cirkel 9b6a93d72c
TryIntoHeaderValue for Uri 2024-08-19 14:12:09 +01:00
8 changed files with 132 additions and 3 deletions

View File

@ -77,7 +77,7 @@ jobs:
run: ./scripts/free-disk-space.sh
- name: Setup mold linker
uses: rui314/setup-mold@7344740a9418dcdcb481c7df83d9fbd1d5072d7d # v1
uses: rui314/setup-mold@725a8794d15fc7563f59595bd9556495c0564878 # v1
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@ab6845274e2ff01cd4462007e1a9d9df1ab49f42 # v1.14.0

View File

@ -56,7 +56,7 @@ jobs:
- name: Setup mold linker
if: matrix.target.os == 'ubuntu-latest'
uses: rui314/setup-mold@7344740a9418dcdcb481c7df83d9fbd1d5072d7d # v1
uses: rui314/setup-mold@725a8794d15fc7563f59595bd9556495c0564878 # v1
- name: Install Rust (${{ matrix.version.name }})
uses: actions-rust-lang/setup-rust-toolchain@ab6845274e2ff01cd4462007e1a9d9df1ab49f42 # v1.14.0

View File

@ -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())
}
}

View File

@ -36,6 +36,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

View File

@ -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"]);
}
}

View File

@ -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"]);
}
}

View File

@ -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`].

View File

@ -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"]);
}
}