mirror of https://github.com/fafhrd91/actix-web
max_http_version to accept http::Version
This commit is contained in:
parent
7a677eafce
commit
de187c0d16
|
@ -164,13 +164,14 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Maximum supported http major version
|
/// Maximum supported http major version
|
||||||
/// When supplied 1 both HTTP/1.0 and HTTP/1.1 will be allowed
|
/// Supported versions http/1.1, http/2
|
||||||
pub fn max_http_version(mut self, val: u8) -> Self {
|
pub fn max_http_version(mut self, val: http::Version) -> Self {
|
||||||
self.ssl = Connector::build_ssl(if val == 1 {
|
let versions = match val {
|
||||||
vec![b"http/1.1".to_vec()]
|
http::Version::HTTP_11 => vec![b"http/1.1".to_vec()],
|
||||||
} else {
|
http::Version::HTTP_2 => vec![b"h2".to_vec(), b"http/1.1".to_vec()],
|
||||||
vec![b"h2".to_vec(), b"http/1.1".to_vec()]
|
_ => unimplemented!("actix-http:client: supported versions http/1.1, http/2"),
|
||||||
});
|
};
|
||||||
|
self.ssl = Connector::build_ssl(versions);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::rc::Rc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use actix_http::client::{Connect as HttpConnect, ConnectError, Connection, Connector};
|
use actix_http::client::{Connect as HttpConnect, ConnectError, Connection, Connector};
|
||||||
use actix_http::http::{header, Error as HttpError, HeaderMap, HeaderName};
|
use actix_http::http::{header, Error as HttpError, HeaderMap, HeaderName, self};
|
||||||
use actix_service::Service;
|
use actix_service::Service;
|
||||||
|
|
||||||
use crate::connect::{ConnectorWrapper, Connect};
|
use crate::connect::{ConnectorWrapper, Connect};
|
||||||
|
@ -19,7 +19,7 @@ pub struct ClientBuilder {
|
||||||
default_headers: bool,
|
default_headers: bool,
|
||||||
allow_redirects: bool,
|
allow_redirects: bool,
|
||||||
max_redirects: usize,
|
max_redirects: usize,
|
||||||
max_http_version: Option<u8>,
|
max_http_version: Option<http::Version>,
|
||||||
stream_window_size: Option<u32>,
|
stream_window_size: Option<u32>,
|
||||||
conn_window_size: Option<u32>,
|
conn_window_size: Option<u32>,
|
||||||
headers: HeaderMap,
|
headers: HeaderMap,
|
||||||
|
@ -84,8 +84,8 @@ impl ClientBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Maximum supported http major version
|
/// Maximum supported http major version
|
||||||
/// When supplied 1 both HTTP/1.0 and HTTP/1.1 will be allowed
|
/// Supported versions http/1.1, http/2
|
||||||
pub fn max_http_version(mut self, val: u8) -> Self {
|
pub fn max_http_version(mut self, val: http::Version) -> Self {
|
||||||
self.max_http_version = Some(val);
|
self.max_http_version = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue