mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-24 08:22:59 +01:00
added TestRequest::set_payload()
This commit is contained in:
parent
6424defee6
commit
979cea03ac
@ -7,6 +7,7 @@ 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};
|
||||||
@ -395,6 +396,14 @@ impl<S> TestRequest<S> {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set request payload
|
||||||
|
pub fn set_payload(mut self, data: Bytes) -> Self {
|
||||||
|
let mut payload = Payload::empty();
|
||||||
|
payload.unread_data(data);
|
||||||
|
self.payload = Some(payload);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Complete request creation and generate `HttpRequest` instance
|
/// Complete request creation and generate `HttpRequest` instance
|
||||||
pub fn finish(self) -> HttpRequest<S> {
|
pub fn finish(self) -> HttpRequest<S> {
|
||||||
let TestRequest { state, method, uri, version, headers, params, cookies, payload } = self;
|
let TestRequest { state, method, uri, version, headers, params, cookies, payload } = self;
|
||||||
|
Loading…
Reference in New Issue
Block a user