Compare commits

...

6 Commits

Author SHA1 Message Date
Armand Mégrot 9d91d301f4
Merge afad1db343 into e1da110e92 2025-11-12 10:12:44 +01:00
Ruchir e1da110e92
chore: Add public export for `EitherExtractError` (#3826)
* chore: Export EitherExtractError for public use

* refactor: export EitherExtractError
2025-11-11 15:28:40 +00:00
Rob Ede afad1db343
Update CHANGES.md 2024-06-11 02:25:08 +01:00
Rob Ede 1098d0deb7
Merge branch 'master' into master 2024-06-11 02:24:26 +01: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
6 changed files with 22 additions and 4 deletions

View File

@ -45,6 +45,10 @@
- Add `error::InvalidStatusCode` re-export. - Add `error::InvalidStatusCode` re-export.
### Fixed
- Fix `MessageType::set_headers` not using the correct payload decoder when Transfer-Encoding and Content-Length are absent.
## 3.7.0 ## 3.7.0
### Added ### Added

View File

@ -391,8 +391,20 @@ impl MessageType for ResponseHead {
// switching protocol or connect // switching protocol or connect
PayloadType::Stream(PayloadDecoder::eof()) PayloadType::Stream(PayloadDecoder::eof())
} else { } else {
// for HTTP/1.0 read to eof and close connection let body_allowed = match msg.status.as_u16() {
if msg.version == Version::HTTP_10 { 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); msg.set_connection_type(ConnectionType::Close);
PayloadType::Payload(PayloadDecoder::eof()) PayloadType::Payload(PayloadDecoder::eof())
} else { } else {

View File

@ -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 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. - `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 `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 ## 4.11.0

View File

@ -21,6 +21,7 @@ mod response_error;
pub(crate) use self::macros::{downcast_dyn, downcast_get_type_id}; pub(crate) use self::macros::{downcast_dyn, downcast_get_type_id};
pub use self::{error::Error, internal::*, response_error::ResponseError}; pub use self::{error::Error, internal::*, response_error::ResponseError};
pub use crate::types::EitherExtractError;
/// A convenience [`Result`](std::result::Result) for Actix Web operations. /// A convenience [`Result`](std::result::Result) for Actix Web operations.
/// ///

View File

@ -11,7 +11,7 @@ mod query;
mod readlines; mod readlines;
pub use self::{ pub use self::{
either::Either, either::{Either, EitherExtractError},
form::{Form, FormConfig, UrlEncoded}, form::{Form, FormConfig, UrlEncoded},
header::Header, header::Header,
html::Html, html::Html,

View File

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