Compare commits

...

7 Commits

Author SHA1 Message Date
Andrew Scott 94f460be97
Merge 845534fc81 into 8996198f2c 2025-08-27 10:24:17 +09:00
Rob Ede 8996198f2c
chore: require h2 versions after MadeYouReset fix 2025-08-26 23:59:57 +01:00
Rob Ede 68624ec63b
chore: remove now-useless docs.rs flags 2025-08-26 23:51:22 +01:00
Rob Ede bcd0ffb016
chore: add multi-crate publish script 2025-08-26 09:25:22 +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 54 additions and 64 deletions

View File

@ -17,7 +17,6 @@ edition.workspace = true
rust-version.workspace = true
[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
features = [
"http2",
"ws",
@ -119,7 +118,7 @@ tokio-util = { version = "0.7", features = ["io", "codec"] }
tracing = { version = "0.1.30", default-features = false, features = ["log"] }
# http2
h2 = { version = "0.3.26", optional = true }
h2 = { version = "0.3.27", optional = true }
# websockets
base64 = { version = "0.22", optional = true }

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

@ -11,7 +11,6 @@ edition.workspace = true
rust-version.workspace = true
[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
all-features = true
[lib]

View File

@ -14,7 +14,6 @@ license.workspace = true
edition.workspace = true
[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
all-features = true
[package.metadata.cargo_check_external_types]

View File

@ -17,7 +17,6 @@ edition.workspace = true
rust-version.workspace = true
[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
features = [
"macros",
"openssl",

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

@ -16,7 +16,6 @@ license = "MIT OR Apache-2.0"
edition = "2021"
[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
features = [
"cookies",
"openssl",
@ -109,7 +108,7 @@ cfg-if = "1"
derive_more = { version = "2", features = ["display", "error", "from"] }
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.26"
h2 = "0.3.27"
http = "0.2.7"
itoa = "1"
log = "0.4"

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

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# developed on macOS and probably doesn't work on Linux yet due to minor
# differences in flags on sed

View File

@ -1,38 +0,0 @@
#!/bin/sh
# run tests matching what CI does for non-linux feature sets
set -x
EXIT=0
save_exit_code() {
eval $@
local CMD_EXIT=$?
[ "$CMD_EXIT" = "0" ] || EXIT=$CMD_EXIT
}
save_exit_code cargo test --lib --tests -p=actix-router --all-features -- --nocapture
save_exit_code cargo test --lib --tests -p=actix-http --all-features -- --nocapture
save_exit_code cargo test --lib --tests -p=actix-web --features=rustls,openssl -- --nocapture
save_exit_code cargo test --lib --tests -p=actix-web-codegen --all-features -- --nocapture
save_exit_code cargo test --lib --tests -p=awc --all-features -- --nocapture
save_exit_code cargo test --lib --tests -p=actix-http-test --all-features -- --nocapture
save_exit_code cargo test --lib --tests -p=actix-test --all-features -- --nocapture
save_exit_code cargo test --lib --tests -p=actix-files -- --nocapture
save_exit_code cargo test --lib --tests -p=actix-multipart --all-features -- --nocapture
save_exit_code cargo test --lib --tests -p=actix-web-actors --all-features -- --nocapture
save_exit_code cargo test --workspace --doc
if [ "$EXIT" = "0" ]; then
PASSED="All tests passed!"
if [ "$(command -v figlet)" ]; then
figlet "$PASSED"
else
echo "$PASSED"
fi
fi
exit $EXIT

25
scripts/publish Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -Euo pipefail
for dir in $@; do
cd "$dir"
cargo publish --dry-run
read -p "Look okay? "
read -p "Sure? "
cargo publish
if [ $? -ne 0 ]; then
echo
read -p "Was the above error caused by cyclic dev-deps? Choosing yes will publish without a git backreference. (y/N) " publish_no_dev_deps
if [[ "$publish_no_dev_deps" == "y" || "$publish_no_dev_deps" == "Y" ]]; then
cargo hack --no-dev-deps publish --allow-dirty
fi
fi
cd ..
done