1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-11-20 08:31:09 +00:00

allocate buffer for request payload extractors

This commit is contained in:
Nikolay Kim 2018-07-16 00:40:22 +06:00
parent 30c84786b7
commit 3373847a14
3 changed files with 5 additions and 5 deletions

View file

@ -36,7 +36,7 @@ script:
fi fi
- | - |
if [[ "$TRAVIS_RUST_VERSION" == "stable" ]]; then if [[ "$TRAVIS_RUST_VERSION" == "stable" ]]; then
RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install cargo-tarpaulin RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install -f cargo-tarpaulin
cargo tarpaulin --features="alpn,tls" --out Xml --no-count cargo tarpaulin --features="alpn,tls" --out Xml --no-count
bash <(curl -s https://codecov.io/bash) bash <(curl -s https://codecov.io/bash)
echo "Uploaded code coverage" echo "Uploaded code coverage"

View file

@ -286,7 +286,7 @@ impl<T: HttpMessage> Readlines<T> {
fn err(req: &T, err: ReadlinesError) -> Self { fn err(req: &T, err: ReadlinesError) -> Self {
Readlines { Readlines {
stream: req.payload(), stream: req.payload(),
buff: BytesMut::with_capacity(262_144), buff: BytesMut::new(),
limit: 262_144, limit: 262_144,
checked_buff: true, checked_buff: true,
encoding: UTF_8, encoding: UTF_8,
@ -472,7 +472,7 @@ where
.take() .take()
.expect("Can not be used second time") .expect("Can not be used second time")
.from_err() .from_err()
.fold(BytesMut::new(), move |mut body, chunk| { .fold(BytesMut::with_capacity(8192), move |mut body, chunk| {
if (body.len() + chunk.len()) > limit { if (body.len() + chunk.len()) > limit {
Err(PayloadError::Overflow) Err(PayloadError::Overflow)
} else { } else {
@ -581,7 +581,7 @@ where
.take() .take()
.expect("UrlEncoded could not be used second time") .expect("UrlEncoded could not be used second time")
.from_err() .from_err()
.fold(BytesMut::new(), move |mut body, chunk| { .fold(BytesMut::with_capacity(8192), move |mut body, chunk| {
if (body.len() + chunk.len()) > limit { if (body.len() + chunk.len()) > limit {
Err(UrlencodedError::Overflow) Err(UrlencodedError::Overflow)
} else { } else {

View file

@ -320,7 +320,7 @@ impl<T: HttpMessage + 'static, U: DeserializeOwned + 'static> Future for JsonBod
.take() .take()
.expect("JsonBody could not be used second time") .expect("JsonBody could not be used second time")
.from_err() .from_err()
.fold(BytesMut::new(), move |mut body, chunk| { .fold(BytesMut::with_capacity(8192), move |mut body, chunk| {
if (body.len() + chunk.len()) > limit { if (body.len() + chunk.len()) > limit {
Err(JsonPayloadError::Overflow) Err(JsonPayloadError::Overflow)
} else { } else {