Skip to content

Commit

Permalink
allocate buffer for request payload extractors
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Jul 15, 2018
1 parent 30c8478 commit 3373847
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ script:
fi
- |
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
bash <(curl -s https://codecov.io/bash)
echo "Uploaded code coverage"
Expand Down
6 changes: 3 additions & 3 deletions src/httpmessage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ impl<T: HttpMessage> Readlines<T> {
fn err(req: &T, err: ReadlinesError) -> Self {
Readlines {
stream: req.payload(),
buff: BytesMut::with_capacity(262_144),
buff: BytesMut::new(),
limit: 262_144,
checked_buff: true,
encoding: UTF_8,
Expand Down Expand Up @@ -472,7 +472,7 @@ where
.take()
.expect("Can not be used second time")
.from_err()
.fold(BytesMut::new(), move |mut body, chunk| {
.fold(BytesMut::with_capacity(8192), move |mut body, chunk| {
if (body.len() + chunk.len()) > limit {
Err(PayloadError::Overflow)
} else {
Expand Down Expand Up @@ -581,7 +581,7 @@ where
.take()
.expect("UrlEncoded could not be used second time")
.from_err()
.fold(BytesMut::new(), move |mut body, chunk| {
.fold(BytesMut::with_capacity(8192), move |mut body, chunk| {
if (body.len() + chunk.len()) > limit {
Err(UrlencodedError::Overflow)
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ impl<T: HttpMessage + 'static, U: DeserializeOwned + 'static> Future for JsonBod
.take()
.expect("JsonBody could not be used second time")
.from_err()
.fold(BytesMut::new(), move |mut body, chunk| {
.fold(BytesMut::with_capacity(8192), move |mut body, chunk| {
if (body.len() + chunk.len()) > limit {
Err(JsonPayloadError::Overflow)
} else {
Expand Down

0 comments on commit 3373847

Please sign in to comment.