1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-25 09:59:21 +02:00

use ParseError for HttpRequest::chunked()

This commit is contained in:
Nikolay Kim
2017-10-16 10:31:31 -07:00
parent 95fa70d19e
commit ff6779a38e
2 changed files with 29 additions and 5 deletions

View File

@ -1,11 +1,12 @@
//! Pieces pertaining to the HTTP message protocol.
use std::{io, str};
//! HTTP Request message related code.
use std::str;
use url::form_urlencoded;
use http::{header, Method, Version, Uri, HeaderMap};
use Params;
use {Cookie, CookieParseError};
use {HttpRange, HttpRangeParseError};
use error::ParseError;
#[derive(Debug)]
@ -162,13 +163,12 @@ impl HttpRequest {
}
/// Check if request has chunked transfer encoding
pub fn chunked(&self) -> Result<bool, io::Error> {
pub fn chunked(&self) -> Result<bool, ParseError> {
if let Some(encodings) = self.headers().get(header::TRANSFER_ENCODING) {
if let Ok(s) = encodings.to_str() {
Ok(s.to_lowercase().contains("chunked"))
} else {
Err(io::Error::new(
io::ErrorKind::Other, "Can not read transfer-encoding header"))
Err(ParseError::Header)
}
} else {
Ok(false)