1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-05-19 16:58:14 +00:00

Compare commits

...

3 commits

Author SHA1 Message Date
Armand Mégrot ffdb8c8009
Merge 5dcad17a61 into 5a5486b484 2024-04-12 13:48:37 -04:00
Armand Mégrot 5dcad17a61
Merge branch 'master' into master 2023-09-12 10:51:58 +02:00
Armand Mégrot 5f1a4607e5
fix response body when no content-length header 2023-05-20 13:30:46 +02:00
3 changed files with 19 additions and 3 deletions

View file

@ -47,6 +47,10 @@
- Minimum supported Rust version (MSRV) is now 1.68 due to transitive `time` dependency.
### Fixed
- Fix `MessageType::set_headers` not using the correct payload decoder when Transfer-Encoding and Content-Length are absent.
## 3.3.1
### Fixed

View file

@ -391,8 +391,20 @@ impl MessageType for ResponseHead {
// switching protocol or connect
PayloadType::Stream(PayloadDecoder::eof())
} else {
// for HTTP/1.0 read to eof and close connection
if msg.version == Version::HTTP_10 {
let body_allowed = match msg.status.as_u16() {
100..=199 => false,
204 => false,
304 => false,
_ => true,
};
// for HTTP/1.0 and HTTP/1.1 read to eof and close connection
if msg.version == Version::HTTP_11 && body_allowed {
if let Some(ConnectionType::Close) = msg.conn_type() {
PayloadType::Payload(PayloadDecoder::eof())
} else {
PayloadType::None
}
} else if msg.version == Version::HTTP_10 {
msg.set_connection_type(ConnectionType::Close);
PayloadType::Payload(PayloadDecoder::eof())
} else {

View file

@ -761,7 +761,7 @@ async fn client_unread_response() {
// awc does not read all bytes unless content-length is specified
let bytes = res.body().await.unwrap();
assert_eq!(bytes, Bytes::from_static(b""));
assert_eq!(bytes, Bytes::from_static(b"welcome!"));
}
#[actix_rt::test]