Skip to content

Commit

Permalink
handle chunked responses
Browse files Browse the repository at this point in the history
  • Loading branch information
jkarneges committed Apr 25, 2024
1 parent 21eb21f commit 7223eb4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/http1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1584,9 +1584,11 @@ impl ClientResponse {
}

state.ver_min = version;
state.chunked = false;

if chunked {
state.body_size = BodySize::Unknown;
state.chunked = true;
} else if let Some(len) = content_len {
state.body_size = BodySize::Known(len);
state.chunk_left = Some(len);
Expand Down Expand Up @@ -4502,6 +4504,7 @@ mod tests {
ver_min: u8,
chunk_left: Option<usize>,
persistent: bool,
chunked: bool,
rbuf_position: u64,
}

Expand All @@ -4513,6 +4516,7 @@ mod tests {
ver_min: 0,
chunk_left: None,
persistent: false,
chunked: false,
rbuf_position: 0,
},
Test {
Expand All @@ -4522,6 +4526,7 @@ mod tests {
ver_min: 0,
chunk_left: None,
persistent: false,
chunked: false,
rbuf_position: 0,
},
Test {
Expand All @@ -4531,6 +4536,7 @@ mod tests {
ver_min: 0,
chunk_left: None,
persistent: false,
chunked: false,
rbuf_position: 0,
},
Test {
Expand All @@ -4540,6 +4546,7 @@ mod tests {
ver_min: 0,
chunk_left: None,
persistent: false,
chunked: false,
rbuf_position: 0,
},
Test {
Expand All @@ -4557,6 +4564,7 @@ mod tests {
ver_min: 0,
chunk_left: None,
persistent: false,
chunked: false,
rbuf_position: 37,
},
Test {
Expand All @@ -4574,6 +4582,7 @@ mod tests {
ver_min: 0,
chunk_left: Some(42),
persistent: false,
chunked: false,
rbuf_position: 39,
},
Test {
Expand All @@ -4588,6 +4597,7 @@ mod tests {
ver_min: 0,
chunk_left: None,
persistent: false,
chunked: false,
rbuf_position: 19,
},
Test {
Expand All @@ -4605,6 +4615,7 @@ mod tests {
ver_min: 0,
chunk_left: None,
persistent: false,
chunked: true,
rbuf_position: 47,
},
Test {
Expand All @@ -4628,6 +4639,7 @@ mod tests {
ver_min: 0,
chunk_left: Some(5),
persistent: true,
chunked: false,
rbuf_position: 62,
},
Test {
Expand All @@ -4645,6 +4657,7 @@ mod tests {
ver_min: 1,
chunk_left: Some(5),
persistent: true,
chunked: false,
rbuf_position: 38,
},
Test {
Expand All @@ -4662,6 +4675,7 @@ mod tests {
ver_min: 1,
chunk_left: None,
persistent: false,
chunked: false,
rbuf_position: 38,
},
];
Expand Down Expand Up @@ -4699,6 +4713,7 @@ mod tests {
"test={}",
test.name
);
assert_eq!(resp_body.state.chunked, test.chunked, "test={}", test.name);

rbuf_position = (src.len() - resp.remaining_bytes().len()) as u64
}
Expand Down

0 comments on commit 7223eb4

Please sign in to comment.