mirror of https://github.com/fafhrd91/actix-web
make content encoding non exhaustive
This commit is contained in:
parent
622ac575ae
commit
c33b3133c0
|
@ -18,6 +18,7 @@
|
||||||
### Fixed
|
### Fixed
|
||||||
* Potential HTTP request smuggling vulnerabilities. [RUSTSEC-2021-0081](https://github.com/rustsec/advisory-db/pull/977)
|
* Potential HTTP request smuggling vulnerabilities. [RUSTSEC-2021-0081](https://github.com/rustsec/advisory-db/pull/977)
|
||||||
|
|
||||||
|
|
||||||
## 3.0.0-beta.8 - 2021-06-26
|
## 3.0.0-beta.8 - 2021-06-26
|
||||||
### Changed
|
### Changed
|
||||||
* Change compression algorithm features flags. [#2250]
|
* Change compression algorithm features flags. [#2250]
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
//! Stream decoders.
|
//! Stream decoders.
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
convert::TryFrom,
|
|
||||||
future::Future,
|
future::Future,
|
||||||
io::{self, Write as _},
|
io::{self, Write as _},
|
||||||
pin::Pin,
|
pin::Pin,
|
||||||
|
@ -81,7 +80,7 @@ where
|
||||||
let encoding = headers
|
let encoding = headers
|
||||||
.get(&CONTENT_ENCODING)
|
.get(&CONTENT_ENCODING)
|
||||||
.and_then(|val| val.to_str().ok())
|
.and_then(|val| val.to_str().ok())
|
||||||
.and_then(|x| ContentEncoding::try_from(x).ok())
|
.and_then(|x| x.parse().ok())
|
||||||
.unwrap_or(ContentEncoding::Identity);
|
.unwrap_or(ContentEncoding::Identity);
|
||||||
|
|
||||||
Self::new(stream, encoding)
|
Self::new(stream, encoding)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use std::{convert::TryFrom, error, fmt, str::FromStr};
|
use std::{convert::TryFrom, str::FromStr};
|
||||||
|
|
||||||
|
use derive_more::{Display, Error};
|
||||||
use http::header::InvalidHeaderValue;
|
use http::header::InvalidHeaderValue;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -11,19 +12,13 @@ use crate::{
|
||||||
/// Error return when a content encoding is unknown.
|
/// Error return when a content encoding is unknown.
|
||||||
///
|
///
|
||||||
/// Example: 'compress'
|
/// Example: 'compress'
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Display, Error)]
|
||||||
|
#[display(fmt = "unsupported content encoding")]
|
||||||
pub struct ContentEncodingParseError;
|
pub struct ContentEncodingParseError;
|
||||||
|
|
||||||
impl fmt::Display for ContentEncodingParseError {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
write!(f, "Unsupported content encoding")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl error::Error for ContentEncodingParseError {}
|
|
||||||
|
|
||||||
/// Represents a supported content encoding.
|
/// Represents a supported content encoding.
|
||||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum ContentEncoding {
|
pub enum ContentEncoding {
|
||||||
/// Automatically select encoding based on encoding negotiation.
|
/// Automatically select encoding based on encoding negotiation.
|
||||||
Auto,
|
Auto,
|
||||||
|
|
Loading…
Reference in New Issue