mirror of https://github.com/fafhrd91/actix-web
Renamed Send->SendBody
This commit is contained in:
parent
5f0b43da7c
commit
faa4ad980f
|
@ -396,7 +396,7 @@ impl ClientRequest {
|
||||||
pub fn send_body<B>(
|
pub fn send_body<B>(
|
||||||
self,
|
self,
|
||||||
body: B,
|
body: B,
|
||||||
) -> Send
|
) -> SendBody
|
||||||
where
|
where
|
||||||
B: Into<Body>,
|
B: Into<Body>,
|
||||||
{
|
{
|
||||||
|
@ -413,7 +413,7 @@ impl ClientRequest {
|
||||||
pub fn send_json<T: Serialize>(
|
pub fn send_json<T: Serialize>(
|
||||||
self,
|
self,
|
||||||
value: &T,
|
value: &T,
|
||||||
) -> Send
|
) -> SendBody
|
||||||
{
|
{
|
||||||
let slf = match self.prep_for_sending() {
|
let slf = match self.prep_for_sending() {
|
||||||
Ok(slf) => slf,
|
Ok(slf) => slf,
|
||||||
|
@ -430,7 +430,7 @@ impl ClientRequest {
|
||||||
pub fn send_form<T: Serialize>(
|
pub fn send_form<T: Serialize>(
|
||||||
self,
|
self,
|
||||||
value: &T,
|
value: &T,
|
||||||
) -> Send
|
) -> SendBody
|
||||||
{
|
{
|
||||||
let slf = match self.prep_for_sending() {
|
let slf = match self.prep_for_sending() {
|
||||||
Ok(slf) => slf,
|
Ok(slf) => slf,
|
||||||
|
@ -445,7 +445,7 @@ impl ClientRequest {
|
||||||
pub fn send_stream<S, E>(
|
pub fn send_stream<S, E>(
|
||||||
self,
|
self,
|
||||||
stream: S,
|
stream: S,
|
||||||
) -> Send
|
) -> SendBody
|
||||||
where
|
where
|
||||||
S: Stream<Item = Bytes, Error = E> + 'static,
|
S: Stream<Item = Bytes, Error = E> + 'static,
|
||||||
E: Into<Error> + 'static,
|
E: Into<Error> + 'static,
|
||||||
|
@ -462,7 +462,7 @@ impl ClientRequest {
|
||||||
/// Set an empty body and generate `ClientRequest`.
|
/// Set an empty body and generate `ClientRequest`.
|
||||||
pub fn send(
|
pub fn send(
|
||||||
self,
|
self,
|
||||||
) -> Send
|
) -> SendBody
|
||||||
{
|
{
|
||||||
let slf = match self.prep_for_sending() {
|
let slf = match self.prep_for_sending() {
|
||||||
Ok(slf) => slf,
|
Ok(slf) => slf,
|
||||||
|
@ -584,7 +584,7 @@ impl FrozenClientRequest {
|
||||||
pub fn send_body<B>(
|
pub fn send_body<B>(
|
||||||
&self,
|
&self,
|
||||||
body: B,
|
body: B,
|
||||||
) -> Send
|
) -> SendBody
|
||||||
where
|
where
|
||||||
B: Into<Body>,
|
B: Into<Body>,
|
||||||
{
|
{
|
||||||
|
@ -596,7 +596,7 @@ impl FrozenClientRequest {
|
||||||
pub fn send_json<T: Serialize>(
|
pub fn send_json<T: Serialize>(
|
||||||
&self,
|
&self,
|
||||||
value: &T,
|
value: &T,
|
||||||
) -> Send
|
) -> SendBody
|
||||||
{
|
{
|
||||||
RequestSender::Rc(self.head.clone(), None)
|
RequestSender::Rc(self.head.clone(), None)
|
||||||
.send_json(self.addr, self.response_decompress, self.timeout, self.config.as_ref(), value)
|
.send_json(self.addr, self.response_decompress, self.timeout, self.config.as_ref(), value)
|
||||||
|
@ -606,7 +606,7 @@ impl FrozenClientRequest {
|
||||||
pub fn send_form<T: Serialize>(
|
pub fn send_form<T: Serialize>(
|
||||||
&self,
|
&self,
|
||||||
value: &T,
|
value: &T,
|
||||||
) -> Send
|
) -> SendBody
|
||||||
{
|
{
|
||||||
RequestSender::Rc(self.head.clone(), None)
|
RequestSender::Rc(self.head.clone(), None)
|
||||||
.send_form(self.addr, self.response_decompress, self.timeout, self.config.as_ref(), value)
|
.send_form(self.addr, self.response_decompress, self.timeout, self.config.as_ref(), value)
|
||||||
|
@ -616,7 +616,7 @@ impl FrozenClientRequest {
|
||||||
pub fn send_stream<S, E>(
|
pub fn send_stream<S, E>(
|
||||||
&self,
|
&self,
|
||||||
stream: S,
|
stream: S,
|
||||||
) -> Send
|
) -> SendBody
|
||||||
where
|
where
|
||||||
S: Stream<Item = Bytes, Error = E> + 'static,
|
S: Stream<Item = Bytes, Error = E> + 'static,
|
||||||
E: Into<Error> + 'static,
|
E: Into<Error> + 'static,
|
||||||
|
@ -628,7 +628,7 @@ impl FrozenClientRequest {
|
||||||
/// Send an empty body.
|
/// Send an empty body.
|
||||||
pub fn send(
|
pub fn send(
|
||||||
&self,
|
&self,
|
||||||
) -> Send
|
) -> SendBody
|
||||||
{
|
{
|
||||||
RequestSender::Rc(self.head.clone(), None)
|
RequestSender::Rc(self.head.clone(), None)
|
||||||
.send(self.addr, self.response_decompress, self.timeout, self.config.as_ref())
|
.send(self.addr, self.response_decompress, self.timeout, self.config.as_ref())
|
||||||
|
@ -684,7 +684,7 @@ impl FrozenSendBuilder {
|
||||||
pub fn send_body<B>(
|
pub fn send_body<B>(
|
||||||
self,
|
self,
|
||||||
body: B,
|
body: B,
|
||||||
) -> Send
|
) -> SendBody
|
||||||
where
|
where
|
||||||
B: Into<Body>,
|
B: Into<Body>,
|
||||||
{
|
{
|
||||||
|
@ -700,7 +700,7 @@ impl FrozenSendBuilder {
|
||||||
pub fn send_json<T: Serialize>(
|
pub fn send_json<T: Serialize>(
|
||||||
self,
|
self,
|
||||||
value: &T,
|
value: &T,
|
||||||
) -> Send
|
) -> SendBody
|
||||||
{
|
{
|
||||||
if let Some(e) = self.err {
|
if let Some(e) = self.err {
|
||||||
return e.into()
|
return e.into()
|
||||||
|
@ -714,7 +714,7 @@ impl FrozenSendBuilder {
|
||||||
pub fn send_form<T: Serialize>(
|
pub fn send_form<T: Serialize>(
|
||||||
self,
|
self,
|
||||||
value: &T,
|
value: &T,
|
||||||
) -> Send
|
) -> SendBody
|
||||||
{
|
{
|
||||||
if let Some(e) = self.err {
|
if let Some(e) = self.err {
|
||||||
return e.into()
|
return e.into()
|
||||||
|
@ -728,7 +728,7 @@ impl FrozenSendBuilder {
|
||||||
pub fn send_stream<S, E>(
|
pub fn send_stream<S, E>(
|
||||||
self,
|
self,
|
||||||
stream: S,
|
stream: S,
|
||||||
) -> Send
|
) -> SendBody
|
||||||
where
|
where
|
||||||
S: Stream<Item = Bytes, Error = E> + 'static,
|
S: Stream<Item = Bytes, Error = E> + 'static,
|
||||||
E: Into<Error> + 'static,
|
E: Into<Error> + 'static,
|
||||||
|
@ -744,7 +744,7 @@ impl FrozenSendBuilder {
|
||||||
/// Complete request construction and send an empty body.
|
/// Complete request construction and send an empty body.
|
||||||
pub fn send(
|
pub fn send(
|
||||||
self,
|
self,
|
||||||
) -> Send
|
) -> SendBody
|
||||||
{
|
{
|
||||||
if let Some(e) = self.err {
|
if let Some(e) = self.err {
|
||||||
return e.into()
|
return e.into()
|
||||||
|
@ -779,33 +779,33 @@ impl Into<SendRequestError> for PrepForSendingError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Send
|
pub enum SendBody
|
||||||
{
|
{
|
||||||
Fut(Box<dyn Future<Item = ClientResponse, Error = SendRequestError>>, Option<Delay>, bool),
|
Fut(Box<dyn Future<Item = ClientResponse, Error = SendRequestError>>, Option<Delay>, bool),
|
||||||
Err(Option<SendRequestError>),
|
Err(Option<SendRequestError>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Send
|
impl SendBody
|
||||||
{
|
{
|
||||||
pub fn new(
|
pub fn new(
|
||||||
send: Box<dyn Future<Item = ClientResponse, Error = SendRequestError>>,
|
send: Box<dyn Future<Item = ClientResponse, Error = SendRequestError>>,
|
||||||
response_decompress: bool,
|
response_decompress: bool,
|
||||||
timeout: Option<Duration>,
|
timeout: Option<Duration>,
|
||||||
) -> Send
|
) -> SendBody
|
||||||
{
|
{
|
||||||
let delay = timeout.map(|t| Delay::new(Instant::now() + t));
|
let delay = timeout.map(|t| Delay::new(Instant::now() + t));
|
||||||
Send::Fut(send, delay, response_decompress)
|
SendBody::Fut(send, delay, response_decompress)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Future for Send
|
impl Future for SendBody
|
||||||
{
|
{
|
||||||
type Item = ClientResponse<Decoder<Payload<PayloadStream>>>;
|
type Item = ClientResponse<Decoder<Payload<PayloadStream>>>;
|
||||||
type Error = SendRequestError;
|
type Error = SendRequestError;
|
||||||
|
|
||||||
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
||||||
match self {
|
match self {
|
||||||
Send::Fut(send, delay, response_decompress) => {
|
SendBody::Fut(send, delay, response_decompress) => {
|
||||||
if delay.is_some() {
|
if delay.is_some() {
|
||||||
match delay.poll() {
|
match delay.poll() {
|
||||||
Ok(Async::NotReady) => (),
|
Ok(Async::NotReady) => (),
|
||||||
|
@ -824,7 +824,7 @@ impl Future for Send
|
||||||
|
|
||||||
Ok(Async::Ready(res))
|
Ok(Async::Ready(res))
|
||||||
},
|
},
|
||||||
Send::Err(ref mut e) => {
|
SendBody::Err(ref mut e) => {
|
||||||
match e.take() {
|
match e.take() {
|
||||||
Some(e) => Err(e.into()),
|
Some(e) => Err(e.into()),
|
||||||
None => panic!("Attempting to call completed future"),
|
None => panic!("Attempting to call completed future"),
|
||||||
|
@ -835,31 +835,31 @@ impl Future for Send
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl From<SendRequestError> for Send
|
impl From<SendRequestError> for SendBody
|
||||||
{
|
{
|
||||||
fn from(e: SendRequestError) -> Self {
|
fn from(e: SendRequestError) -> Self {
|
||||||
Send::Err(Some(e))
|
SendBody::Err(Some(e))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Error> for Send
|
impl From<Error> for SendBody
|
||||||
{
|
{
|
||||||
fn from(e: Error) -> Self {
|
fn from(e: Error) -> Self {
|
||||||
Send::Err(Some(e.into()))
|
SendBody::Err(Some(e.into()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<HttpError> for Send
|
impl From<HttpError> for SendBody
|
||||||
{
|
{
|
||||||
fn from(e: HttpError) -> Self {
|
fn from(e: HttpError) -> Self {
|
||||||
Send::Err(Some(e.into()))
|
SendBody::Err(Some(e.into()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<PrepForSendingError> for Send
|
impl From<PrepForSendingError> for SendBody
|
||||||
{
|
{
|
||||||
fn from(e: PrepForSendingError) -> Self {
|
fn from(e: PrepForSendingError) -> Self {
|
||||||
Send::Err(Some(e.into()))
|
SendBody::Err(Some(e.into()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -877,7 +877,7 @@ impl RequestSender {
|
||||||
timeout: Option<Duration>,
|
timeout: Option<Duration>,
|
||||||
config: &ClientConfig,
|
config: &ClientConfig,
|
||||||
body: B,
|
body: B,
|
||||||
) -> Send
|
) -> SendBody
|
||||||
where
|
where
|
||||||
B: Into<Body>,
|
B: Into<Body>,
|
||||||
{
|
{
|
||||||
|
@ -888,7 +888,7 @@ impl RequestSender {
|
||||||
RequestSender::Rc(head, extra_headers) => connector.send_request_extra(head, extra_headers, body.into(), addr),
|
RequestSender::Rc(head, extra_headers) => connector.send_request_extra(head, extra_headers, body.into(), addr),
|
||||||
};
|
};
|
||||||
|
|
||||||
Send::new(fut, response_decompress, timeout.or_else(|| config.timeout.clone()))
|
SendBody::new(fut, response_decompress, timeout.or_else(|| config.timeout.clone()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_json<T: Serialize>(
|
pub fn send_json<T: Serialize>(
|
||||||
|
@ -898,7 +898,7 @@ impl RequestSender {
|
||||||
timeout: Option<Duration>,
|
timeout: Option<Duration>,
|
||||||
config: &ClientConfig,
|
config: &ClientConfig,
|
||||||
value: &T,
|
value: &T,
|
||||||
) -> Send
|
) -> SendBody
|
||||||
{
|
{
|
||||||
let body = match serde_json::to_string(value) {
|
let body = match serde_json::to_string(value) {
|
||||||
Ok(body) => body,
|
Ok(body) => body,
|
||||||
|
@ -919,7 +919,7 @@ impl RequestSender {
|
||||||
timeout: Option<Duration>,
|
timeout: Option<Duration>,
|
||||||
config: &ClientConfig,
|
config: &ClientConfig,
|
||||||
value: &T,
|
value: &T,
|
||||||
) -> Send
|
) -> SendBody
|
||||||
{
|
{
|
||||||
let body = match serde_urlencoded::to_string(value) {
|
let body = match serde_urlencoded::to_string(value) {
|
||||||
Ok(body) => body,
|
Ok(body) => body,
|
||||||
|
@ -941,7 +941,7 @@ impl RequestSender {
|
||||||
timeout: Option<Duration>,
|
timeout: Option<Duration>,
|
||||||
config: &ClientConfig,
|
config: &ClientConfig,
|
||||||
stream: S,
|
stream: S,
|
||||||
) -> Send
|
) -> SendBody
|
||||||
where
|
where
|
||||||
S: Stream<Item = Bytes, Error = E> + 'static,
|
S: Stream<Item = Bytes, Error = E> + 'static,
|
||||||
E: Into<Error> + 'static,
|
E: Into<Error> + 'static,
|
||||||
|
@ -955,7 +955,7 @@ impl RequestSender {
|
||||||
response_decompress: bool,
|
response_decompress: bool,
|
||||||
timeout: Option<Duration>,
|
timeout: Option<Duration>,
|
||||||
config: &ClientConfig,
|
config: &ClientConfig,
|
||||||
) -> Send
|
) -> SendBody
|
||||||
{
|
{
|
||||||
self.send_body(addr, response_decompress, timeout, config, Body::Empty)
|
self.send_body(addr, response_decompress, timeout, config, Body::Empty)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue