mirror of https://github.com/fafhrd91/actix-web
get rid of unwraps
This commit is contained in:
parent
17e9d203ee
commit
e7d96288cd
|
@ -56,6 +56,7 @@ serde_json = "1.0"
|
|||
serde_urlencoded = "0.7"
|
||||
open-ssl = { version = "0.10", package = "openssl", optional = true }
|
||||
rust-tls = { version = "0.18.0", package = "rustls", optional = true, features = ["dangerous_configuration"] }
|
||||
if_chain = "1.0.1"
|
||||
|
||||
[dev-dependencies]
|
||||
actix-connect = { version = "2.0.0", features = ["openssl"] }
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use if_chain::if_chain;
|
||||
use std::cell::RefCell;
|
||||
use std::future::Future;
|
||||
use std::pin::Pin;
|
||||
|
@ -135,15 +136,13 @@ where
|
|||
|
||||
match resp {
|
||||
Ok((resphead, payload)) => {
|
||||
if resphead.status.is_redirection() {
|
||||
reqhead.uri = resphead
|
||||
.headers
|
||||
.get(actix_http::http::header::LOCATION)
|
||||
.unwrap()
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.parse::<Uri>()
|
||||
.unwrap();
|
||||
if_chain! {
|
||||
if resphead.status.is_redirection();
|
||||
if let Some(location_value) = resphead.headers.get(actix_http::http::header::LOCATION);
|
||||
if let Ok(location_str) = location_value.to_str();
|
||||
if let Ok(location_uri) = location_str.parse::<Uri>();
|
||||
then {
|
||||
reqhead.uri = location_uri;
|
||||
return deal_with_redirects(
|
||||
backend.clone(),
|
||||
reqhead,
|
||||
|
@ -152,6 +151,7 @@ where
|
|||
)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
Ok(ClientResponse::new(resphead, payload))
|
||||
}
|
||||
Err(e) => Err(e),
|
||||
|
|
Loading…
Reference in New Issue