From 979cea03acbaff6f17a1b9b554d599af4643288b Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Mon, 19 Feb 2018 20:01:38 -0800 Subject: [PATCH] added TestRequest::set_payload() --- src/test.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/test.rs b/src/test.rs index 86940bc0..4581e9ed 100644 --- a/src/test.rs +++ b/src/test.rs @@ -7,6 +7,7 @@ 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}; @@ -395,6 +396,14 @@ impl TestRequest { 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 pub fn finish(self) -> HttpRequest { let TestRequest { state, method, uri, version, headers, params, cookies, payload } = self;