Compare commits

...

8 Commits

Author SHA1 Message Date
Andrew Scott 22508fcdac
Merge 845534fc81 into 9fb6c13a1a 2025-08-26 10:11:10 +02:00
Rob Ede 9fb6c13a1a
ci: fix msrv job 2025-08-26 08:26:49 +01:00
Rob Ede 05cfef7f4b
ci: fix msrv job 2025-08-26 08:18:34 +01:00
Rob Ede 8f3eb32a32
chore: fix justfile for msrv 2025-08-26 08:00:19 +01:00
Rob Ede ddd16ec9db
chore(actix-http): prepare release 3.11.1 2025-08-26 07:28:27 +01:00
imgurbot12 845534fc81
chore(actix-http): more tests should use proper method 2025-07-30 22:04:48 -07:00
imgurbot12 605bcd18c6
chore(awc): json test should use proper method 2025-07-30 21:08:46 -07:00
imgurbot12 612e983576
fix(awc): some methods incorrectly send body & body-headers 2025-07-30 20:54:48 -07:00
15 changed files with 292 additions and 201 deletions

View File

@ -3,6 +3,6 @@ disallowed-names = [
"e", # no single letter error bindings
]
disallowed-methods = [
{ path = "std::cell::RefCell::default()", reason = "prefer explicit inner type default" },
{ path = "std::rc::Rc::default()", reason = "prefer explicit inner type default" },
{ path = "std::cell::RefCell::default()", reason = "prefer explicit inner type default (remove allow-invalid when rust-lang/rust-clippy/#8581 is fixed)", allow-invalid = true },
{ path = "std::rc::Rc::default()", reason = "prefer explicit inner type default (remove allow-invalid when rust-lang/rust-clippy/#8581 is fixed)", allow-invalid = true },
]

422
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -2,8 +2,11 @@
## Unreleased
- Update `TestRequest::set_payload` to generate "Content-Length" header
- Malformed websocket frames are now gracefully rejected.
## 3.11.1
- Prevent more hangs after client disconnects.
- More malformed WebSocket frames are now gracefully rejected.
- Using `TestRequest::set_payload()` now sets a Content-Length header.
## 3.11.0

View File

@ -1,6 +1,6 @@
[package]
name = "actix-http"
version = "3.11.0"
version = "3.11.1"
authors = ["Nikolay Kim <fafhrd91@gmail.com>", "Rob Ede <robjtede@icloud.com>"]
description = "HTTP types and services for the Actix ecosystem"
keywords = ["actix", "http", "framework", "async", "futures"]

View File

@ -5,11 +5,11 @@
<!-- prettier-ignore-start -->
[![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.11.0)](https://docs.rs/actix-http/3.11.0)
[![Documentation](https://docs.rs/actix-http/badge.svg?version=3.11.1)](https://docs.rs/actix-http/3.11.1)
![Version](https://img.shields.io/badge/rustc-1.72+-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.11.0/status.svg)](https://deps.rs/crate/actix-http/3.11.0)
[![dependency status](https://deps.rs/crate/actix-http/3.11.1/status.svg)](https://deps.rs/crate/actix-http/3.11.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

@ -139,7 +139,7 @@ async fn h1_expect() {
// test expect would fail to continue
let request = srv
.request(http::Method::GET, srv.url("/"))
.request(http::Method::POST, srv.url("/"))
.insert_header(("Expect", "100-continue"));
let response = request.send_body("expect body").await.unwrap();
@ -147,7 +147,7 @@ async fn h1_expect() {
// test expect would continue
let request = srv
.request(http::Method::GET, srv.url("/"))
.request(http::Method::POST, srv.url("/"))
.insert_header(("Expect", "100-continue"))
.insert_header(("AUTH", "996"));

View File

@ -118,7 +118,7 @@ async fn h2_body() -> io::Result<()> {
})
.await;
let response = srv.sget("/").send_body(data.clone()).await.unwrap();
let response = srv.spost("/").send_body(data.clone()).await.unwrap();
assert!(response.status().is_success());
let body = srv.load_body(response).await.unwrap();

View File

@ -184,7 +184,7 @@ async fn h2_body1() -> io::Result<()> {
})
.await;
let response = srv.sget("/").send_body(data.clone()).await.unwrap();
let response = srv.spost("/").send_body(data.clone()).await.unwrap();
assert!(response.status().is_success());
let body = srv.load_body(response).await.unwrap();

View File

@ -13,6 +13,7 @@ macro_rules! register {
register!(finish => "(.*)", "(.*)", "(.*)", "(.*)")
}};
(finish => $p1:literal, $p2:literal, $p3:literal, $p4:literal) => {{
#[expect(clippy::useless_concat)]
let arr = [
concat!("/authorizations"),
concat!("/authorizations/", $p1),

View File

@ -3,7 +3,6 @@
- The return type for `ServiceRequest::app_data::<T>()` was changed from returning a `Data<T>` to simply a `T`. To access a `Data<T>` use `ServiceRequest::app_data::<Data<T>>()`.
- Cookie handling has been offloaded to the `cookie` crate:
- `USERINFO_ENCODE_SET` is no longer exposed. Percent-encoding is still supported; check docs.
- Some types now require lifetime parameters.

View File

@ -2,6 +2,8 @@
## Unreleased
- `GET/HEAD/OPTIONS/TRACE` methods no longer send a request body on request.
## 3.7.0
- Update `brotli` dependency to `8`.

View File

@ -4,8 +4,12 @@ use std::{
task::{Context, Poll},
};
use actix_http::body::{BodySize, BoxBody, MessageBody};
use actix_http::{
body::{BodySize, BoxBody, MessageBody},
RequestHead,
};
use bytes::Bytes;
use http::Method;
use pin_project_lite::pin_project;
pin_project! {
@ -75,11 +79,15 @@ where
/// Converts a [`MessageBody`] type into the best possible representation.
///
/// Checks size for `None` and tries to convert to `Bytes`. Otherwise, uses the `Body` variant.
pub fn from_message_body(body: B) -> Self
pub fn from_message_body(head: &RequestHead, body: B) -> Self
where
B: MessageBody,
{
if matches!(body.size(), BodySize::None) {
if matches!(
head.method,
Method::GET | Method::HEAD | Method::OPTIONS | Method::TRACE
) || matches!(body.size(), BodySize::None)
{
return Self::None;
}

View File

@ -189,16 +189,14 @@ impl RequestSender {
body: impl MessageBody + 'static,
) -> SendClientRequest {
let req = match self {
RequestSender::Owned(head) => ConnectRequest::Client(
RequestHeadType::Owned(head),
AnyBody::from_message_body(body).into_boxed(),
addr,
),
RequestSender::Rc(head, extra_headers) => ConnectRequest::Client(
RequestHeadType::Rc(head, extra_headers),
AnyBody::from_message_body(body).into_boxed(),
addr,
),
RequestSender::Owned(head) => {
let body = AnyBody::from_message_body(&head, body).into_boxed();
ConnectRequest::Client(RequestHeadType::Owned(head), body, addr)
}
RequestSender::Rc(head, extra_headers) => {
let body = AnyBody::from_message_body(&head, body).into_boxed();
ConnectRequest::Client(RequestHeadType::Rc(head, extra_headers), body, addr)
}
};
let fut = config.connector.call(req);

View File

@ -62,7 +62,7 @@ async fn json() {
});
let request = srv
.get("/")
.post("/")
.insert_header(("x-test", "111"))
.send_json(&"TEST".to_string());
let response = request.await.unwrap();

View File

@ -13,6 +13,8 @@ fmt:
[private]
downgrade-for-msrv:
cargo {{ toolchain }} update -p=divan --precise=0.1.15 # next ver: 1.80.0
cargo {{ toolchain }} update -p=rayon --precise=1.10.0 # next ver: 1.80.0
cargo {{ toolchain }} update -p=rayon-core --precise=1.12.1 # next ver: 1.80.0
cargo {{ toolchain }} update -p=half --precise=2.4.1 # next ver: 1.81.0
cargo {{ toolchain }} update -p=idna_adapter --precise=1.2.0 # next ver: 1.82.0
cargo {{ toolchain }} update -p=litemap --precise=0.7.4 # next ver: 1.81.0
@ -50,8 +52,7 @@ clippy:
cargo {{ toolchain }} clippy --workspace --all-targets {{ all_crate_features }}
# Run Clippy over workspace using MSRV.
clippy-msrv:
@just toolchain={{ msrv_rustup }} downgrade-for-msrv
clippy-msrv: downgrade-for-msrv
@just toolchain={{ msrv_rustup }} clippy
# Test workspace code.
@ -62,8 +63,7 @@ test:
cargo {{ toolchain }} nextest run --no-tests=warn --workspace --exclude=actix-web-codegen --exclude=actix-multipart-derive {{ all_crate_features }} --filter-expr="not test(test_reading_deflate_encoding_large_random_rustls)"
# Test workspace using MSRV.
test-msrv:
@just toolchain={{ msrv_rustup }} downgrade-for-msrv
test-msrv: downgrade-for-msrv
@just toolchain={{ msrv_rustup }} test
# Test workspace docs.