1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-11-03 15:39:50 +00:00

allow to pass different binary data

This commit is contained in:
Nikolay Kim 2018-02-19 20:03:57 -08:00
parent 979cea03ac
commit 3f95cce9e8

View file

@ -7,7 +7,6 @@ use std::str::FromStr;
use std::collections::HashMap;
use actix::{Arbiter, Addr, Syn, System, SystemRunner, msgs};
use bytes::Bytes;
use cookie::Cookie;
use http::{Uri, Method, Version, HeaderMap, HttpTryFrom};
use http::header::{HeaderName, HeaderValue};
@ -16,6 +15,7 @@ use tokio_core::net::TcpListener;
use tokio_core::reactor::Core;
use net2::TcpBuilder;
use body::Binary;
use error::Error;
use handler::{Handler, Responder, ReplyItem};
use middleware::Middleware;
@ -397,9 +397,10 @@ impl<S> TestRequest<S> {
}
/// 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();
payload.unread_data(data);
payload.unread_data(data.take());
self.payload = Some(payload);
self
}