mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
Support chunked encoding for UrlEncoded body #262
This commit is contained in:
parent
7ab23d082d
commit
8b8a3ac01d
@ -149,7 +149,6 @@ pub trait HttpMessage {
|
|||||||
/// Returns error:
|
/// Returns error:
|
||||||
///
|
///
|
||||||
/// * content type is not `application/x-www-form-urlencoded`
|
/// * content type is not `application/x-www-form-urlencoded`
|
||||||
/// * transfer encoding is `chunked`.
|
|
||||||
/// * content-length is greater than 256k
|
/// * content-length is greater than 256k
|
||||||
///
|
///
|
||||||
/// ## Server example
|
/// ## Server example
|
||||||
@ -367,9 +366,7 @@ where
|
|||||||
|
|
||||||
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
||||||
if let Some(req) = self.req.take() {
|
if let Some(req) = self.req.take() {
|
||||||
if req.chunked().unwrap_or(false) {
|
if let Some(len) = req.headers().get(header::CONTENT_LENGTH) {
|
||||||
return Err(UrlencodedError::Chunked);
|
|
||||||
} else if let Some(len) = req.headers().get(header::CONTENT_LENGTH) {
|
|
||||||
if let Ok(s) = len.to_str() {
|
if let Ok(s) = len.to_str() {
|
||||||
if let Ok(len) = s.parse::<u64>() {
|
if let Ok(len) = s.parse::<u64>() {
|
||||||
if len > 262_144 {
|
if len > 262_144 {
|
||||||
@ -577,13 +574,6 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_urlencoded_error() {
|
fn test_urlencoded_error() {
|
||||||
let req =
|
|
||||||
TestRequest::with_header(header::TRANSFER_ENCODING, "chunked").finish();
|
|
||||||
assert_eq!(
|
|
||||||
req.urlencoded::<Info>().poll().err().unwrap(),
|
|
||||||
UrlencodedError::Chunked
|
|
||||||
);
|
|
||||||
|
|
||||||
let req = TestRequest::with_header(
|
let req = TestRequest::with_header(
|
||||||
header::CONTENT_TYPE,
|
header::CONTENT_TYPE,
|
||||||
"application/x-www-form-urlencoded",
|
"application/x-www-form-urlencoded",
|
||||||
|
Loading…
Reference in New Issue
Block a user