mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-23 23:51:06 +01:00
clippy warnings
This commit is contained in:
parent
ef3e1037a8
commit
4092c7f326
@ -1,3 +1,4 @@
|
|||||||
|
#![allow(clippy::borrow_interior_mutable_const, clippy::type_complexity)]
|
||||||
//! Cross-origin resource sharing (CORS) for Actix applications
|
//! Cross-origin resource sharing (CORS) for Actix applications
|
||||||
//!
|
//!
|
||||||
//! CORS middleware could be used with application and with resource.
|
//! CORS middleware could be used with application and with resource.
|
||||||
@ -162,6 +163,7 @@ impl<T> AllOrSome<T> {
|
|||||||
/// .max_age(3600);
|
/// .max_age(3600);
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
#[derive(Default)]
|
||||||
pub struct Cors {
|
pub struct Cors {
|
||||||
cors: Option<Inner>,
|
cors: Option<Inner>,
|
||||||
methods: bool,
|
methods: bool,
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#![allow(clippy::borrow_interior_mutable_const, clippy::type_complexity)]
|
||||||
|
|
||||||
//! Static files support
|
//! Static files support
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
@ -57,7 +59,7 @@ pub struct ChunkedReadFile {
|
|||||||
fn handle_error(err: BlockingError<io::Error>) -> Error {
|
fn handle_error(err: BlockingError<io::Error>) -> Error {
|
||||||
match err {
|
match err {
|
||||||
BlockingError::Error(err) => err.into(),
|
BlockingError::Error(err) => err.into(),
|
||||||
BlockingError::Canceled => ErrorInternalServerError("Unexpected error").into(),
|
BlockingError::Canceled => ErrorInternalServerError("Unexpected error"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,8 +24,8 @@ use crate::ChunkedReadFile;
|
|||||||
|
|
||||||
bitflags! {
|
bitflags! {
|
||||||
pub(crate) struct Flags: u32 {
|
pub(crate) struct Flags: u32 {
|
||||||
const ETAG = 0b00000001;
|
const ETAG = 0b0000_0001;
|
||||||
const LAST_MD = 0b00000010;
|
const LAST_MD = 0b0000_0010;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,8 +311,8 @@ impl Responder for NamedFile {
|
|||||||
return Ok(resp.streaming(reader));
|
return Ok(resp.streaming(reader));
|
||||||
}
|
}
|
||||||
|
|
||||||
match req.method() {
|
match *req.method() {
|
||||||
&Method::HEAD | &Method::GET => (),
|
Method::HEAD | Method::GET => (),
|
||||||
_ => {
|
_ => {
|
||||||
return Ok(HttpResponse::MethodNotAllowed()
|
return Ok(HttpResponse::MethodNotAllowed()
|
||||||
.header(header::CONTENT_TYPE, "text/plain")
|
.header(header::CONTENT_TYPE, "text/plain")
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
#![allow(
|
||||||
|
clippy::type_complexity,
|
||||||
|
clippy::new_without_default,
|
||||||
|
dead_code,
|
||||||
|
deprecated
|
||||||
|
)]
|
||||||
mod app;
|
mod app;
|
||||||
mod helpers;
|
mod helpers;
|
||||||
mod request;
|
mod request;
|
||||||
|
@ -333,8 +333,7 @@ struct CookieIdentityExtention {
|
|||||||
|
|
||||||
impl CookieIdentityInner {
|
impl CookieIdentityInner {
|
||||||
fn new(key: &[u8]) -> CookieIdentityInner {
|
fn new(key: &[u8]) -> CookieIdentityInner {
|
||||||
let key_v2: Vec<u8> =
|
let key_v2: Vec<u8> = key.iter().chain([1, 0, 0, 0].iter()).cloned().collect();
|
||||||
key.iter().chain([1, 0, 0, 0].iter()).map(|e| *e).collect();
|
|
||||||
CookieIdentityInner {
|
CookieIdentityInner {
|
||||||
key: Key::from_master(key),
|
key: Key::from_master(key),
|
||||||
key_v2: Key::from_master(&key_v2),
|
key_v2: Key::from_master(&key_v2),
|
||||||
@ -585,13 +584,14 @@ impl IdentityPolicy for CookieIdentityPolicy {
|
|||||||
)
|
)
|
||||||
} else if self.0.always_update_cookie() && id.is_some() {
|
} else if self.0.always_update_cookie() && id.is_some() {
|
||||||
let visit_timestamp = SystemTime::now();
|
let visit_timestamp = SystemTime::now();
|
||||||
let mut login_timestamp = None;
|
let login_timestamp = if self.0.requires_oob_data() {
|
||||||
if self.0.requires_oob_data() {
|
|
||||||
let CookieIdentityExtention {
|
let CookieIdentityExtention {
|
||||||
login_timestamp: lt,
|
login_timestamp: lt,
|
||||||
} = res.request().extensions_mut().remove().unwrap();
|
} = res.request().extensions_mut().remove().unwrap();
|
||||||
login_timestamp = lt;
|
lt
|
||||||
}
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
self.0.set_cookie(
|
self.0.set_cookie(
|
||||||
res,
|
res,
|
||||||
Some(CookieValue {
|
Some(CookieValue {
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#![allow(clippy::borrow_interior_mutable_const)]
|
||||||
|
|
||||||
mod error;
|
mod error;
|
||||||
mod extractor;
|
mod extractor;
|
||||||
mod server;
|
mod server;
|
||||||
|
@ -418,7 +418,7 @@ impl Stream for Field {
|
|||||||
|
|
||||||
inner.poll(&self.safety)
|
inner.poll(&self.safety)
|
||||||
} else if !self.safety.is_clean() {
|
} else if !self.safety.is_clean() {
|
||||||
return Err(MultipartError::NotConsumed);
|
Err(MultipartError::NotConsumed)
|
||||||
} else {
|
} else {
|
||||||
Ok(Async::NotReady)
|
Ok(Async::NotReady)
|
||||||
}
|
}
|
||||||
@ -533,11 +533,9 @@ impl InnerField {
|
|||||||
let b_size = boundary.len() + b_len;
|
let b_size = boundary.len() + b_len;
|
||||||
if len < b_size {
|
if len < b_size {
|
||||||
return Ok(Async::NotReady);
|
return Ok(Async::NotReady);
|
||||||
} else {
|
} else if &payload.buf[b_len..b_size] == boundary.as_bytes() {
|
||||||
if &payload.buf[b_len..b_size] == boundary.as_bytes() {
|
// found boundary
|
||||||
// found boundary
|
return Ok(Async::Ready(None));
|
||||||
return Ok(Async::Ready(None));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -557,7 +555,7 @@ impl InnerField {
|
|||||||
// check boundary
|
// check boundary
|
||||||
if (&payload.buf[cur..cur + 2] == b"\r\n"
|
if (&payload.buf[cur..cur + 2] == b"\r\n"
|
||||||
&& &payload.buf[cur + 2..cur + 4] == b"--")
|
&& &payload.buf[cur + 2..cur + 4] == b"--")
|
||||||
|| (&payload.buf[cur..cur + 1] == b"\r"
|
|| (&payload.buf[cur..=cur] == b"\r"
|
||||||
&& &payload.buf[cur + 1..cur + 3] == b"--")
|
&& &payload.buf[cur + 1..cur + 3] == b"--")
|
||||||
{
|
{
|
||||||
if cur != 0 {
|
if cur != 0 {
|
||||||
|
@ -342,7 +342,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
(SessionStatus::Purged, _) => {
|
(SessionStatus::Purged, _) => {
|
||||||
inner.remove_cookie(&mut res);
|
let _ = inner.remove_cookie(&mut res);
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
_ => res,
|
_ => res,
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#![allow(clippy::borrow_interior_mutable_const)]
|
||||||
//! Actix actors integration for Actix web framework
|
//! Actix actors integration for Actix web framework
|
||||||
mod context;
|
mod context;
|
||||||
pub mod ws;
|
pub mod ws;
|
||||||
|
@ -435,7 +435,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Frame::Binary(data) => Message::Binary(
|
Frame::Binary(data) => Message::Binary(
|
||||||
data.map(|b| b.freeze()).unwrap_or_else(|| Bytes::new()),
|
data.map(|b| b.freeze()).unwrap_or_else(Bytes::new),
|
||||||
),
|
),
|
||||||
Frame::Ping(s) => Message::Ping(s),
|
Frame::Ping(s) => Message::Ping(s),
|
||||||
Frame::Pong(s) => Message::Pong(s),
|
Frame::Pong(s) => Message::Pong(s),
|
||||||
|
@ -12,9 +12,9 @@ enum ResourceType {
|
|||||||
|
|
||||||
impl fmt::Display for ResourceType {
|
impl fmt::Display for ResourceType {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self {
|
match *self {
|
||||||
&ResourceType::Async => write!(f, "to_async"),
|
ResourceType::Async => write!(f, "to_async"),
|
||||||
&ResourceType::Sync => write!(f, "to"),
|
ResourceType::Sync => write!(f, "to"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -34,16 +34,16 @@ pub enum GuardType {
|
|||||||
|
|
||||||
impl fmt::Display for GuardType {
|
impl fmt::Display for GuardType {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self {
|
match *self {
|
||||||
&GuardType::Get => write!(f, "Get"),
|
GuardType::Get => write!(f, "Get"),
|
||||||
&GuardType::Post => write!(f, "Post"),
|
GuardType::Post => write!(f, "Post"),
|
||||||
&GuardType::Put => write!(f, "Put"),
|
GuardType::Put => write!(f, "Put"),
|
||||||
&GuardType::Delete => write!(f, "Delete"),
|
GuardType::Delete => write!(f, "Delete"),
|
||||||
&GuardType::Head => write!(f, "Head"),
|
GuardType::Head => write!(f, "Head"),
|
||||||
&GuardType::Connect => write!(f, "Connect"),
|
GuardType::Connect => write!(f, "Connect"),
|
||||||
&GuardType::Options => write!(f, "Options"),
|
GuardType::Options => write!(f, "Options"),
|
||||||
&GuardType::Trace => write!(f, "Trace"),
|
GuardType::Trace => write!(f, "Trace"),
|
||||||
&GuardType::Patch => write!(f, "Patch"),
|
GuardType::Patch => write!(f, "Patch"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,37 +92,27 @@ impl actix_web::dev::HttpServiceFactory for {name} {{
|
|||||||
fn guess_resource_type(typ: &syn::Type) -> ResourceType {
|
fn guess_resource_type(typ: &syn::Type) -> ResourceType {
|
||||||
let mut guess = ResourceType::Sync;
|
let mut guess = ResourceType::Sync;
|
||||||
|
|
||||||
match typ {
|
if let syn::Type::ImplTrait(typ) = typ {
|
||||||
syn::Type::ImplTrait(typ) => {
|
for bound in typ.bounds.iter() {
|
||||||
for bound in typ.bounds.iter() {
|
if let syn::TypeParamBound::Trait(bound) = bound {
|
||||||
match bound {
|
for bound in bound.path.segments.iter() {
|
||||||
syn::TypeParamBound::Trait(bound) => {
|
if bound.ident == "Future" {
|
||||||
for bound in bound.path.segments.iter() {
|
guess = ResourceType::Async;
|
||||||
if bound.ident == "Future" {
|
break;
|
||||||
guess = ResourceType::Async;
|
} else if bound.ident == "Responder" {
|
||||||
break;
|
guess = ResourceType::Sync;
|
||||||
} else if bound.ident == "Responder" {
|
break;
|
||||||
guess = ResourceType::Sync;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
guess
|
guess
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Args {
|
impl Args {
|
||||||
pub fn new(
|
pub fn new(args: &[syn::NestedMeta], input: TokenStream, guard: GuardType) -> Self {
|
||||||
args: &Vec<syn::NestedMeta>,
|
|
||||||
input: TokenStream,
|
|
||||||
guard: GuardType,
|
|
||||||
) -> Self {
|
|
||||||
if args.is_empty() {
|
if args.is_empty() {
|
||||||
panic!(
|
panic!(
|
||||||
"invalid server definition, expected: #[{}(\"some path\")]",
|
"invalid server definition, expected: #[{}(\"some path\")]",
|
||||||
@ -164,9 +154,10 @@ impl Args {
|
|||||||
ResourceType::Async
|
ResourceType::Async
|
||||||
} else {
|
} else {
|
||||||
match ast.decl.output {
|
match ast.decl.output {
|
||||||
syn::ReturnType::Default => {
|
syn::ReturnType::Default => panic!(
|
||||||
panic!("Function {} has no return type. Cannot be used as handler")
|
"Function {} has no return type. Cannot be used as handler",
|
||||||
}
|
name
|
||||||
|
),
|
||||||
syn::ReturnType::Type(_, ref typ) => guess_resource_type(typ.as_ref()),
|
syn::ReturnType::Type(_, ref typ) => guess_resource_type(typ.as_ref()),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -21,6 +21,12 @@ pub struct ClientBuilder {
|
|||||||
max_redirects: usize,
|
max_redirects: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for ClientBuilder {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl ClientBuilder {
|
impl ClientBuilder {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
ClientBuilder {
|
ClientBuilder {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#![allow(clippy::borrow_interior_mutable_const)]
|
||||||
//! An HTTP Client
|
//! An HTTP Client
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
|
@ -185,9 +185,7 @@ impl ClientRequest {
|
|||||||
{
|
{
|
||||||
match HeaderName::try_from(key) {
|
match HeaderName::try_from(key) {
|
||||||
Ok(key) => match value.try_into() {
|
Ok(key) => match value.try_into() {
|
||||||
Ok(value) => {
|
Ok(value) => self.head.headers.append(key, value),
|
||||||
let _ = self.head.headers.append(key, value);
|
|
||||||
}
|
|
||||||
Err(e) => self.err = Some(e.into()),
|
Err(e) => self.err = Some(e.into()),
|
||||||
},
|
},
|
||||||
Err(e) => self.err = Some(e.into()),
|
Err(e) => self.err = Some(e.into()),
|
||||||
@ -203,9 +201,7 @@ impl ClientRequest {
|
|||||||
{
|
{
|
||||||
match HeaderName::try_from(key) {
|
match HeaderName::try_from(key) {
|
||||||
Ok(key) => match value.try_into() {
|
Ok(key) => match value.try_into() {
|
||||||
Ok(value) => {
|
Ok(value) => self.head.headers.insert(key, value),
|
||||||
let _ = self.head.headers.insert(key, value);
|
|
||||||
}
|
|
||||||
Err(e) => self.err = Some(e.into()),
|
Err(e) => self.err = Some(e.into()),
|
||||||
},
|
},
|
||||||
Err(e) => self.err = Some(e.into()),
|
Err(e) => self.err = Some(e.into()),
|
||||||
@ -223,9 +219,7 @@ impl ClientRequest {
|
|||||||
Ok(key) => {
|
Ok(key) => {
|
||||||
if !self.head.headers.contains_key(&key) {
|
if !self.head.headers.contains_key(&key) {
|
||||||
match value.try_into() {
|
match value.try_into() {
|
||||||
Ok(value) => {
|
Ok(value) => self.head.headers.insert(key, value),
|
||||||
let _ = self.head.headers.insert(key, value);
|
|
||||||
}
|
|
||||||
Err(e) => self.err = Some(e.into()),
|
Err(e) => self.err = Some(e.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -257,9 +251,7 @@ impl ClientRequest {
|
|||||||
HeaderValue: HttpTryFrom<V>,
|
HeaderValue: HttpTryFrom<V>,
|
||||||
{
|
{
|
||||||
match HeaderValue::try_from(value) {
|
match HeaderValue::try_from(value) {
|
||||||
Ok(value) => {
|
Ok(value) => self.head.headers.insert(header::CONTENT_TYPE, value),
|
||||||
let _ = self.head.headers.insert(header::CONTENT_TYPE, value);
|
|
||||||
}
|
|
||||||
Err(e) => self.err = Some(e.into()),
|
Err(e) => self.err = Some(e.into()),
|
||||||
}
|
}
|
||||||
self
|
self
|
||||||
@ -321,7 +313,7 @@ impl ClientRequest {
|
|||||||
/// }));
|
/// }));
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn cookie<'c>(mut self, cookie: Cookie<'c>) -> Self {
|
pub fn cookie(mut self, cookie: Cookie<'_>) -> Self {
|
||||||
if self.cookies.is_none() {
|
if self.cookies.is_none() {
|
||||||
let mut jar = CookieJar::new();
|
let mut jar = CookieJar::new();
|
||||||
jar.add(cookie.into_owned());
|
jar.add(cookie.into_owned());
|
||||||
@ -465,7 +457,7 @@ impl ClientRequest {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// set request timeout
|
// set request timeout
|
||||||
if let Some(timeout) = slf.timeout.or_else(|| config.timeout.clone()) {
|
if let Some(timeout) = slf.timeout.or_else(|| config.timeout) {
|
||||||
Either::B(Either::A(Timeout::new(fut, timeout).map_err(|e| {
|
Either::B(Either::A(Timeout::new(fut, timeout).map_err(|e| {
|
||||||
if let Some(e) = e.into_inner() {
|
if let Some(e) = e.into_inner() {
|
||||||
e
|
e
|
||||||
|
@ -68,7 +68,7 @@ impl TestResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Set cookie for this response
|
/// Set cookie for this response
|
||||||
pub fn cookie<'a>(mut self, cookie: Cookie<'a>) -> Self {
|
pub fn cookie(mut self, cookie: Cookie<'_>) -> Self {
|
||||||
self.cookies.add(cookie.into_owned());
|
self.cookies.add(cookie.into_owned());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ impl WebsocketsRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Set a cookie
|
/// Set a cookie
|
||||||
pub fn cookie<'c>(mut self, cookie: Cookie<'c>) -> Self {
|
pub fn cookie(mut self, cookie: Cookie<'_>) -> Self {
|
||||||
if self.cookies.is_none() {
|
if self.cookies.is_none() {
|
||||||
let mut jar = CookieJar::new();
|
let mut jar = CookieJar::new();
|
||||||
jar.add(cookie.into_owned());
|
jar.add(cookie.into_owned());
|
||||||
|
@ -25,11 +25,7 @@ impl ConnectionInfo {
|
|||||||
Ref::map(req.extensions(), |e| e.get().unwrap())
|
Ref::map(req.extensions(), |e| e.get().unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(
|
#[allow(clippy::cognitive_complexity)]
|
||||||
clippy::cyclomatic_complexity,
|
|
||||||
clippy::cognitive_complexity,
|
|
||||||
clippy::borrow_interior_mutable_const
|
|
||||||
)]
|
|
||||||
fn new(req: &RequestHead, cfg: &AppConfig) -> ConnectionInfo {
|
fn new(req: &RequestHead, cfg: &AppConfig) -> ConnectionInfo {
|
||||||
let mut host = None;
|
let mut host = None;
|
||||||
let mut scheme = None;
|
let mut scheme = None;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#![allow(clippy::borrow_interior_mutable_const)]
|
||||||
//! Actix web is a small, pragmatic, and extremely fast web framework
|
//! Actix web is a small, pragmatic, and extremely fast web framework
|
||||||
//! for Rust.
|
//! for Rust.
|
||||||
//!
|
//!
|
||||||
|
@ -107,7 +107,6 @@ where
|
|||||||
self.service.poll_ready()
|
self.service.poll_ready()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::borrow_interior_mutable_const)]
|
|
||||||
fn call(&mut self, req: ServiceRequest) -> Self::Future {
|
fn call(&mut self, req: ServiceRequest) -> Self::Future {
|
||||||
// negotiate content-encoding
|
// negotiate content-encoding
|
||||||
let encoding = if let Some(val) = req.headers().get(&ACCEPT_ENCODING) {
|
let encoding = if let Some(val) = req.headers().get(&ACCEPT_ENCODING) {
|
||||||
|
@ -125,7 +125,6 @@ where
|
|||||||
self.service.poll_ready()
|
self.service.poll_ready()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::borrow_interior_mutable_const)]
|
|
||||||
fn call(&mut self, req: ServiceRequest) -> Self::Future {
|
fn call(&mut self, req: ServiceRequest) -> Self::Future {
|
||||||
let inner = self.inner.clone();
|
let inner = self.inner.clone();
|
||||||
|
|
||||||
|
@ -288,13 +288,13 @@ where
|
|||||||
lst,
|
lst,
|
||||||
move || {
|
move || {
|
||||||
let c = cfg.lock();
|
let c = cfg.lock();
|
||||||
acceptor.clone().map_err(|e| SslError::Ssl(e)).and_then(
|
acceptor.clone().map_err(SslError::Ssl).and_then(
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.keep_alive(c.keep_alive)
|
.keep_alive(c.keep_alive)
|
||||||
.client_timeout(c.client_timeout)
|
.client_timeout(c.client_timeout)
|
||||||
.client_disconnect(c.client_shutdown)
|
.client_disconnect(c.client_shutdown)
|
||||||
.finish(factory())
|
.finish(factory())
|
||||||
.map_err(|e| SslError::Service(e))
|
.map_err(SslError::Service)
|
||||||
.map_init_err(|_| ()),
|
.map_init_err(|_| ()),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@ -339,13 +339,13 @@ where
|
|||||||
lst,
|
lst,
|
||||||
move || {
|
move || {
|
||||||
let c = cfg.lock();
|
let c = cfg.lock();
|
||||||
acceptor.clone().map_err(|e| SslError::Ssl(e)).and_then(
|
acceptor.clone().map_err(SslError::Ssl).and_then(
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.keep_alive(c.keep_alive)
|
.keep_alive(c.keep_alive)
|
||||||
.client_timeout(c.client_timeout)
|
.client_timeout(c.client_timeout)
|
||||||
.client_disconnect(c.client_shutdown)
|
.client_disconnect(c.client_shutdown)
|
||||||
.finish(factory())
|
.finish(factory())
|
||||||
.map_err(|e| SslError::Service(e))
|
.map_err(SslError::Service)
|
||||||
.map_init_err(|_| ()),
|
.map_init_err(|_| ()),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@ -79,7 +79,7 @@ where
|
|||||||
F: FnOnce() -> R,
|
F: FnOnce() -> R,
|
||||||
R: IntoFuture,
|
R: IntoFuture,
|
||||||
{
|
{
|
||||||
RT.with(move |rt| rt.borrow_mut().get_mut().block_on(lazy(|| f())))
|
RT.with(move |rt| rt.borrow_mut().get_mut().block_on(lazy(f)))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
|
@ -192,7 +192,6 @@ pub struct UrlEncoded<U> {
|
|||||||
|
|
||||||
impl<U> UrlEncoded<U> {
|
impl<U> UrlEncoded<U> {
|
||||||
/// Create a new future to URL encode a request
|
/// Create a new future to URL encode a request
|
||||||
#[allow(clippy::borrow_interior_mutable_const)]
|
|
||||||
pub fn new(req: &HttpRequest, payload: &mut Payload) -> UrlEncoded<U> {
|
pub fn new(req: &HttpRequest, payload: &mut Payload) -> UrlEncoded<U> {
|
||||||
// check content type
|
// check content type
|
||||||
if req.content_type().to_lowercase() != "application/x-www-form-urlencoded" {
|
if req.content_type().to_lowercase() != "application/x-www-form-urlencoded" {
|
||||||
|
@ -298,7 +298,6 @@ where
|
|||||||
U: DeserializeOwned + 'static,
|
U: DeserializeOwned + 'static,
|
||||||
{
|
{
|
||||||
/// Create `JsonBody` for request.
|
/// Create `JsonBody` for request.
|
||||||
#[allow(clippy::borrow_interior_mutable_const)]
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
req: &HttpRequest,
|
req: &HttpRequest,
|
||||||
payload: &mut Payload,
|
payload: &mut Payload,
|
||||||
|
@ -298,7 +298,6 @@ pub struct HttpMessageBody {
|
|||||||
|
|
||||||
impl HttpMessageBody {
|
impl HttpMessageBody {
|
||||||
/// Create `MessageBody` for request.
|
/// Create `MessageBody` for request.
|
||||||
#[allow(clippy::borrow_interior_mutable_const)]
|
|
||||||
pub fn new(req: &HttpRequest, payload: &mut dev::Payload) -> HttpMessageBody {
|
pub fn new(req: &HttpRequest, payload: &mut dev::Payload) -> HttpMessageBody {
|
||||||
let mut len = None;
|
let mut len = None;
|
||||||
if let Some(l) = req.headers().get(&header::CONTENT_LENGTH) {
|
if let Some(l) = req.headers().get(&header::CONTENT_LENGTH) {
|
||||||
|
@ -65,7 +65,7 @@ where
|
|||||||
F: FnOnce() -> R,
|
F: FnOnce() -> R,
|
||||||
R: IntoFuture,
|
R: IntoFuture,
|
||||||
{
|
{
|
||||||
RT.with(move |rt| rt.borrow_mut().get_mut().block_on(lazy(|| f())))
|
RT.with(move |rt| rt.borrow_mut().get_mut().block_on(lazy(f)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The `TestServer` type.
|
/// The `TestServer` type.
|
||||||
@ -107,6 +107,7 @@ pub struct TestServerRuntime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TestServer {
|
impl TestServer {
|
||||||
|
#[allow(clippy::new_ret_no_self)]
|
||||||
/// Start new test server with application factory
|
/// Start new test server with application factory
|
||||||
pub fn new<F: StreamServiceFactory>(factory: F) -> TestServerRuntime {
|
pub fn new<F: StreamServiceFactory>(factory: F) -> TestServerRuntime {
|
||||||
let (tx, rx) = mpsc::channel();
|
let (tx, rx) = mpsc::channel();
|
||||||
@ -191,7 +192,7 @@ impl TestServerRuntime {
|
|||||||
F: FnOnce() -> R,
|
F: FnOnce() -> R,
|
||||||
R: Future,
|
R: Future,
|
||||||
{
|
{
|
||||||
self.rt.block_on(lazy(|| f()))
|
self.rt.block_on(lazy(f))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Execute function on current core
|
/// Execute function on current core
|
||||||
|
Loading…
Reference in New Issue
Block a user