mirror of https://github.com/fafhrd91/actix-web
Compare commits
4 Commits
05e50ece7c
...
77b152ec5c
Author | SHA1 | Date |
---|---|---|
|
77b152ec5c | |
|
3f9d88f859 | |
|
2eb801cb59 | |
|
296d546ca4 |
|
@ -49,7 +49,7 @@ jobs:
|
||||||
toolchain: ${{ matrix.version.version }}
|
toolchain: ${{ matrix.version.version }}
|
||||||
|
|
||||||
- name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean
|
- name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean
|
||||||
uses: taiki-e/install-action@v2.54.0
|
uses: taiki-e/install-action@v2.54.3
|
||||||
with:
|
with:
|
||||||
tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean
|
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
|
uses: actions-rust-lang/setup-rust-toolchain@v1.13.0
|
||||||
|
|
||||||
- name: Install just, cargo-hack
|
- name: Install just, cargo-hack
|
||||||
uses: taiki-e/install-action@v2.54.0
|
uses: taiki-e/install-action@v2.54.3
|
||||||
with:
|
with:
|
||||||
tool: just,cargo-hack
|
tool: just,cargo-hack
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ jobs:
|
||||||
toolchain: ${{ matrix.version.version }}
|
toolchain: ${{ matrix.version.version }}
|
||||||
|
|
||||||
- name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean
|
- name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean
|
||||||
uses: taiki-e/install-action@v2.54.0
|
uses: taiki-e/install-action@v2.54.3
|
||||||
with:
|
with:
|
||||||
tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean
|
tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ jobs:
|
||||||
toolchain: nightly
|
toolchain: nightly
|
||||||
|
|
||||||
- name: Install just
|
- name: Install just
|
||||||
uses: taiki-e/install-action@v2.54.0
|
uses: taiki-e/install-action@v2.54.3
|
||||||
with:
|
with:
|
||||||
tool: just
|
tool: just
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ jobs:
|
||||||
components: llvm-tools
|
components: llvm-tools
|
||||||
|
|
||||||
- name: Install just, cargo-llvm-cov, cargo-nextest
|
- name: Install just, cargo-llvm-cov, cargo-nextest
|
||||||
uses: taiki-e/install-action@v2.54.0
|
uses: taiki-e/install-action@v2.54.3
|
||||||
with:
|
with:
|
||||||
tool: just,cargo-llvm-cov,cargo-nextest
|
tool: just,cargo-llvm-cov,cargo-nextest
|
||||||
|
|
||||||
|
|
|
@ -77,12 +77,12 @@ jobs:
|
||||||
toolchain: ${{ vars.RUST_VERSION_EXTERNAL_TYPES }}
|
toolchain: ${{ vars.RUST_VERSION_EXTERNAL_TYPES }}
|
||||||
|
|
||||||
- name: Install just
|
- name: Install just
|
||||||
uses: taiki-e/install-action@v2.54.0
|
uses: taiki-e/install-action@v2.54.3
|
||||||
with:
|
with:
|
||||||
tool: just
|
tool: just
|
||||||
|
|
||||||
- name: Install cargo-check-external-types
|
- name: Install cargo-check-external-types
|
||||||
uses: taiki-e/cache-cargo-install-action@v2.1.2
|
uses: taiki-e/cache-cargo-install-action@v2.2.0
|
||||||
with:
|
with:
|
||||||
tool: cargo-check-external-types
|
tool: cargo-check-external-types
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,9 @@
|
||||||
- Add `body::to_bytes_limited()` function.
|
- Add `body::to_bytes_limited()` function.
|
||||||
- Add `body::BodyLimitExceeded` error type.
|
- Add `body::BodyLimitExceeded` error type.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fix truncated body ending without error when connection closed abnormally. [#3067]
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Minimum supported Rust version (MSRV) is now 1.68 due to transitive `time` dependency.
|
- Minimum supported Rust version (MSRV) is now 1.68 due to transitive `time` dependency.
|
||||||
|
|
|
@ -1118,6 +1118,7 @@ where
|
||||||
let inner = inner.as_mut().project();
|
let inner = inner.as_mut().project();
|
||||||
inner.flags.insert(Flags::READ_DISCONNECT);
|
inner.flags.insert(Flags::READ_DISCONNECT);
|
||||||
if let Some(mut payload) = inner.payload.take() {
|
if let Some(mut payload) = inner.payload.take() {
|
||||||
|
payload.set_error(io::Error::from(io::ErrorKind::UnexpectedEof).into());
|
||||||
payload.feed_eof();
|
payload.feed_eof();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -443,6 +443,60 @@ async fn content_length() {
|
||||||
srv.stop().await;
|
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]
|
#[actix_rt::test]
|
||||||
async fn h1_headers() {
|
async fn h1_headers() {
|
||||||
let data = STR.repeat(10);
|
let data = STR.repeat(10);
|
||||||
|
|
Loading…
Reference in New Issue