mirror of https://github.com/fafhrd91/actix-web
fix: include content-length with bytes payload
This commit is contained in:
parent
b6ad483699
commit
83e521c933
|
@ -2,6 +2,8 @@
|
|||
|
||||
## Unreleased
|
||||
|
||||
- Update `TestRequest::set_payload` to generate "Content-Length" header
|
||||
|
||||
## 3.11.0
|
||||
|
||||
- Update `brotli` dependency to `8`.
|
||||
|
|
|
@ -11,7 +11,7 @@ use std::{
|
|||
|
||||
use actix_codec::{AsyncRead, AsyncWrite, ReadBuf};
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use http::{Method, Uri, Version};
|
||||
use http::{header, Method, Uri, Version};
|
||||
|
||||
use crate::{
|
||||
header::{HeaderMap, TryIntoHeaderPair},
|
||||
|
@ -100,7 +100,9 @@ impl TestRequest {
|
|||
/// Set request payload.
|
||||
pub fn set_payload(&mut self, data: impl Into<Bytes>) -> &mut Self {
|
||||
let mut payload = crate::h1::Payload::empty();
|
||||
payload.unread_data(data.into());
|
||||
let bytes = data.into();
|
||||
self.insert_header((header::CONTENT_LENGTH, bytes.len()));
|
||||
payload.unread_data(bytes);
|
||||
parts(&mut self.0).payload = Some(payload.into());
|
||||
self
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue