mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-30 18:34:36 +01:00
Fix client request timeout handling
This commit is contained in:
parent
c172deb0f3
commit
92f993e054
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
* Added error response functions for 501,502,503,504
|
* Added error response functions for 501,502,503,504
|
||||||
|
|
||||||
|
* Fix client request timeout handling
|
||||||
|
|
||||||
|
|
||||||
## 0.6.2 (2018-05-09)
|
## 0.6.2 (2018-05-09)
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ use httpresponse::HttpResponse;
|
|||||||
impl ResponseError for SendRequestError {
|
impl ResponseError for SendRequestError {
|
||||||
fn error_response(&self) -> HttpResponse {
|
fn error_response(&self) -> HttpResponse {
|
||||||
match *self {
|
match *self {
|
||||||
|
SendRequestError::Timeout => HttpResponse::GatewayTimeout(),
|
||||||
SendRequestError::Connector(_) => HttpResponse::BadGateway(),
|
SendRequestError::Connector(_) => HttpResponse::BadGateway(),
|
||||||
_ => HttpResponse::InternalServerError(),
|
_ => HttpResponse::InternalServerError(),
|
||||||
}.into()
|
}.into()
|
||||||
|
@ -194,6 +194,7 @@ impl Future for SendRequest {
|
|||||||
self.state = State::Send(pl);
|
self.state = State::Send(pl);
|
||||||
}
|
}
|
||||||
State::Send(mut pl) => {
|
State::Send(mut pl) => {
|
||||||
|
pl.poll_timeout()?;
|
||||||
pl.poll_write().map_err(|e| {
|
pl.poll_write().map_err(|e| {
|
||||||
io::Error::new(io::ErrorKind::Other, format!("{}", e).as_str())
|
io::Error::new(io::ErrorKind::Other, format!("{}", e).as_str())
|
||||||
})?;
|
})?;
|
||||||
@ -315,7 +316,7 @@ impl Pipeline {
|
|||||||
{
|
{
|
||||||
Async::NotReady => need_run = true,
|
Async::NotReady => need_run = true,
|
||||||
Async::Ready(_) => {
|
Async::Ready(_) => {
|
||||||
let _ = self.poll_timeout().map_err(|e| {
|
self.poll_timeout().map_err(|e| {
|
||||||
io::Error::new(io::ErrorKind::Other, format!("{}", e))
|
io::Error::new(io::ErrorKind::Other, format!("{}", e))
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
@ -371,16 +372,15 @@ impl Pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll_timeout(&mut self) -> Poll<(), SendRequestError> {
|
fn poll_timeout(&mut self) -> Result<(), SendRequestError> {
|
||||||
if self.timeout.is_some() {
|
if self.timeout.is_some() {
|
||||||
match self.timeout.as_mut().unwrap().poll() {
|
match self.timeout.as_mut().unwrap().poll() {
|
||||||
Ok(Async::Ready(())) => Err(SendRequestError::Timeout),
|
Ok(Async::Ready(())) => return Err(SendRequestError::Timeout),
|
||||||
Ok(Async::NotReady) => Ok(Async::NotReady),
|
Ok(Async::NotReady) => (),
|
||||||
Err(_) => unreachable!(),
|
Err(_) => unreachable!(),
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Ok(Async::NotReady)
|
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
Loading…
Reference in New Issue
Block a user