mirror of https://github.com/fafhrd91/actix-web
Compare commits
5 Commits
81ebb59721
...
f0e3a15f79
| Author | SHA1 | Date |
|---|---|---|
|
|
f0e3a15f79 | |
|
|
e1da110e92 | |
|
|
219b988300 | |
|
|
9cf3521390 | |
|
|
296d546ca4 |
|
|
@ -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@f535147c22906d77695e11cb199e764aa610a4fc # v2.62.46
|
||||
uses: taiki-e/install-action@44c6d64aa62cd779e873306675c7a58e86d6d532 # v2.62.49
|
||||
with:
|
||||
tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ jobs:
|
|||
uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2
|
||||
|
||||
- name: Install just, cargo-hack
|
||||
uses: taiki-e/install-action@f535147c22906d77695e11cb199e764aa610a4fc # v2.62.46
|
||||
uses: taiki-e/install-action@44c6d64aa62cd779e873306675c7a58e86d6d532 # v2.62.49
|
||||
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@f535147c22906d77695e11cb199e764aa610a4fc # v2.62.46
|
||||
uses: taiki-e/install-action@44c6d64aa62cd779e873306675c7a58e86d6d532 # v2.62.49
|
||||
with:
|
||||
tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean
|
||||
|
||||
|
|
@ -117,7 +117,7 @@ jobs:
|
|||
toolchain: nightly
|
||||
|
||||
- name: Install just
|
||||
uses: taiki-e/install-action@f535147c22906d77695e11cb199e764aa610a4fc # v2.62.46
|
||||
uses: taiki-e/install-action@44c6d64aa62cd779e873306675c7a58e86d6d532 # v2.62.49
|
||||
with:
|
||||
tool: just
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ jobs:
|
|||
components: llvm-tools
|
||||
|
||||
- name: Install just, cargo-llvm-cov, cargo-nextest
|
||||
uses: taiki-e/install-action@f535147c22906d77695e11cb199e764aa610a4fc # v2.62.46
|
||||
uses: taiki-e/install-action@44c6d64aa62cd779e873306675c7a58e86d6d532 # v2.62.49
|
||||
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@f535147c22906d77695e11cb199e764aa610a4fc # v2.62.46
|
||||
uses: taiki-e/install-action@44c6d64aa62cd779e873306675c7a58e86d6d532 # v2.62.49
|
||||
with:
|
||||
tool: just
|
||||
|
||||
|
|
|
|||
|
|
@ -2377,9 +2377,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.41"
|
||||
version = "1.0.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1"
|
||||
checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -94,6 +94,9 @@
|
|||
- Add `body::to_bytes_limited()` function.
|
||||
- Add `body::BodyLimitExceeded` error type.
|
||||
|
||||
### Fixed
|
||||
- Fix truncated body ending without error when connection closed abnormally. [#3067]
|
||||
|
||||
### Changed
|
||||
|
||||
- Minimum supported Rust version (MSRV) is now 1.68 due to transitive `time` dependency.
|
||||
|
|
|
|||
|
|
@ -1156,6 +1156,7 @@ where
|
|||
let inner = inner.as_mut().project();
|
||||
inner.flags.insert(Flags::READ_DISCONNECT);
|
||||
if let Some(mut payload) = inner.payload.take() {
|
||||
payload.set_error(io::Error::from(io::ErrorKind::UnexpectedEof).into());
|
||||
payload.feed_eof();
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -443,6 +443,60 @@ async fn content_length() {
|
|||
srv.stop().await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn content_length_truncated() {
|
||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||
|
||||
let mut srv = test_server(|| {
|
||||
HttpService::build()
|
||||
.h1(|mut req: Request| async move {
|
||||
let expected_length: usize = req.uri().path()[1..].parse().unwrap();
|
||||
let mut payload = req.take_payload();
|
||||
|
||||
let mut length = 0;
|
||||
let mut seen_error = false;
|
||||
while let Some(chunk) = payload.next().await {
|
||||
match chunk {
|
||||
Ok(b) => length += b.len(),
|
||||
Err(_) => {
|
||||
seen_error = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if seen_error {
|
||||
return Result::<_, Infallible>::Ok(Response::bad_request());
|
||||
}
|
||||
|
||||
assert_eq!(length, expected_length, "length must match when no error");
|
||||
Result::<_, Infallible>::Ok(Response::ok())
|
||||
})
|
||||
.tcp()
|
||||
})
|
||||
.await;
|
||||
|
||||
let addr = srv.addr();
|
||||
let mut buf = [0; 12];
|
||||
|
||||
let mut conn = TcpStream::connect(&addr).await.unwrap();
|
||||
conn.write_all(b"POST /10000 HTTP/1.1\r\nContent-Length: 10000\r\n\r\ndata_truncated")
|
||||
.await
|
||||
.unwrap();
|
||||
conn.shutdown().await.unwrap();
|
||||
conn.read_exact(&mut buf).await.unwrap();
|
||||
assert_eq!(&buf, b"HTTP/1.1 400");
|
||||
|
||||
let mut conn = TcpStream::connect(&addr).await.unwrap();
|
||||
conn.write_all(b"POST /4 HTTP/1.1\r\nContent-Length: 4\r\n\r\ndata")
|
||||
.await
|
||||
.unwrap();
|
||||
conn.shutdown().await.unwrap();
|
||||
conn.read_exact(&mut buf).await.unwrap();
|
||||
assert_eq!(&buf, b"HTTP/1.1 200");
|
||||
|
||||
srv.stop().await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn h1_headers() {
|
||||
let data = STR.repeat(10);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
- `actix_web::response::builder::HttpResponseBuilder::streaming()` now sets `Content-Type` to `application/octet-stream` if `Content-Type` does not exist.
|
||||
- `actix_web::response::builder::HttpResponseBuilder::streaming()` now calls `actix_web::response::builder::HttpResponseBuilder::no_chunking()` if `Content-Length` is set by user.
|
||||
- Add `ws` crate feature (on-by-default) which forwards to `actix-http` and guards some of its `ResponseError` impls.
|
||||
- Add public export for `EitherExtractError` in `error` module.
|
||||
|
||||
## 4.11.0
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ mod response_error;
|
|||
|
||||
pub(crate) use self::macros::{downcast_dyn, downcast_get_type_id};
|
||||
pub use self::{error::Error, internal::*, response_error::ResponseError};
|
||||
pub use crate::types::EitherExtractError;
|
||||
|
||||
/// A convenience [`Result`](std::result::Result) for Actix Web operations.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ mod query;
|
|||
mod readlines;
|
||||
|
||||
pub use self::{
|
||||
either::Either,
|
||||
either::{Either, EitherExtractError},
|
||||
form::{Form, FormConfig, UrlEncoded},
|
||||
header::Header,
|
||||
html::Html,
|
||||
|
|
|
|||
Loading…
Reference in New Issue