mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-24 08:22:59 +01:00
allow to pass different binary data
This commit is contained in:
parent
979cea03ac
commit
3f95cce9e8
@ -7,7 +7,6 @@ use std::str::FromStr;
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use actix::{Arbiter, Addr, Syn, System, SystemRunner, msgs};
|
use actix::{Arbiter, Addr, Syn, System, SystemRunner, msgs};
|
||||||
use bytes::Bytes;
|
|
||||||
use cookie::Cookie;
|
use cookie::Cookie;
|
||||||
use http::{Uri, Method, Version, HeaderMap, HttpTryFrom};
|
use http::{Uri, Method, Version, HeaderMap, HttpTryFrom};
|
||||||
use http::header::{HeaderName, HeaderValue};
|
use http::header::{HeaderName, HeaderValue};
|
||||||
@ -16,6 +15,7 @@ use tokio_core::net::TcpListener;
|
|||||||
use tokio_core::reactor::Core;
|
use tokio_core::reactor::Core;
|
||||||
use net2::TcpBuilder;
|
use net2::TcpBuilder;
|
||||||
|
|
||||||
|
use body::Binary;
|
||||||
use error::Error;
|
use error::Error;
|
||||||
use handler::{Handler, Responder, ReplyItem};
|
use handler::{Handler, Responder, ReplyItem};
|
||||||
use middleware::Middleware;
|
use middleware::Middleware;
|
||||||
@ -397,9 +397,10 @@ impl<S> TestRequest<S> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Set request payload
|
/// Set request payload
|
||||||
pub fn set_payload(mut self, data: Bytes) -> Self {
|
pub fn set_payload<B: Into<Binary>>(mut self, data: B) -> Self {
|
||||||
|
let mut data = data.into();
|
||||||
let mut payload = Payload::empty();
|
let mut payload = Payload::empty();
|
||||||
payload.unread_data(data);
|
payload.unread_data(data.take());
|
||||||
self.payload = Some(payload);
|
self.payload = Some(payload);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user