return NeedMoreData when ContentLength and empty chunk
Otherwise, we get stuck in a loop if the buffer is empty
This commit is contained in:
parent
8014ec4076
commit
29a2fd3c7f
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
/target
|
||||||
17
Cargo.lock
generated
Normal file
17
Cargo.lock
generated
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "uhttp"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"uhttp-ext",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "uhttp-ext"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"uhttp",
|
||||||
|
]
|
||||||
|
|
@ -168,6 +168,9 @@ impl Connection {
|
||||||
|
|
||||||
(_, StateRecv::Body(body_state)) => match body_state {
|
(_, StateRecv::Body(body_state)) => match body_state {
|
||||||
BodyState::ContentLength(remaining) => {
|
BodyState::ContentLength(remaining) => {
|
||||||
|
if bytes.is_empty() && *remaining != 0 {
|
||||||
|
return fail(ErrorKind::NeedMoreData).tup(bytes);
|
||||||
|
}
|
||||||
if bytes.len() < *remaining {
|
if bytes.len() < *remaining {
|
||||||
Ok((
|
Ok((
|
||||||
&[] as &[u8],
|
&[] as &[u8],
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue