1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-11-23 10:01:06 +00:00

drop deprecated code

This commit is contained in:
Nikolay Kim 2018-03-29 11:06:44 -07:00
parent ae6c9cb7fa
commit f5636f321b
18 changed files with 61 additions and 152 deletions

View file

@ -1,6 +1,6 @@
# Changes # Changes
## 0.4.11 ## 0.5.0
* Type-safe path/query parameter handling, using serde #70 * Type-safe path/query parameter handling, using serde #70

View file

@ -172,12 +172,11 @@ and is on for *HTTP/1.1* and *HTTP/2.0*.
```rust ```rust
# extern crate actix_web; # extern crate actix_web;
# use actix_web::httpcodes::*; use actix_web::{header, HttpRequest, HttpResponse, httpcodes::HttpOk};
use actix_web::*;
fn index(req: HttpRequest) -> HttpResponse { fn index(req: HttpRequest) -> HttpResponse {
HttpOk.build() HttpOk.build()
.connection_type(headers::ConnectionType::Close) // <- Close connection .connection_type(header::ConnectionType::Close) // <- Close connection
.force_close() // <- Alternative method .force_close() // <- Alternative method
.finish().unwrap() .finish().unwrap()
} }

View file

@ -12,8 +12,7 @@ builder instance multiple times, the builder will panic.
```rust ```rust
# extern crate actix_web; # extern crate actix_web;
use actix_web::*; use actix_web::{HttpRequest, HttpResponse, header::ContentEncoding};
use actix_web::headers::ContentEncoding;
fn index(req: HttpRequest) -> HttpResponse { fn index(req: HttpRequest) -> HttpResponse {
HttpResponse::Ok() HttpResponse::Ok()
@ -46,8 +45,7 @@ to enable `brotli` use `ContentEncoding::Br`:
```rust ```rust
# extern crate actix_web; # extern crate actix_web;
use actix_web::*; use actix_web::{HttpRequest, HttpResponse, header::ContentEncoding};
use actix_web::headers::ContentEncoding;
fn index(req: HttpRequest) -> HttpResponse { fn index(req: HttpRequest) -> HttpResponse {
HttpResponse::Ok() HttpResponse::Ok()

View file

@ -6,7 +6,7 @@ use std::collections::HashMap;
use handler::Reply; use handler::Reply;
use router::{Router, Pattern}; use router::{Router, Pattern};
use resource::Resource; use resource::Resource;
use headers::ContentEncoding; use header::ContentEncoding;
use handler::{Handler, RouteHandler, WrapHandler}; use handler::{Handler, RouteHandler, WrapHandler};
use httprequest::HttpRequest; use httprequest::HttpRequest;
use pipeline::{Pipeline, PipelineHandler}; use pipeline::{Pipeline, PipelineHandler};

View file

@ -11,7 +11,7 @@ use actix::prelude::*;
use error::Error; use error::Error;
use body::{Body, BodyStream}; use body::{Body, BodyStream};
use context::{Frame, ActorHttpContext}; use context::{Frame, ActorHttpContext};
use headers::ContentEncoding; use header::ContentEncoding;
use httpmessage::HttpMessage; use httpmessage::HttpMessage;
use error::PayloadError; use error::PayloadError;
use server::WriterState; use server::WriterState;

View file

@ -449,7 +449,7 @@ impl ClientRequestBuilder {
/// # use actix_web::*; /// # use actix_web::*;
/// # use actix_web::httpcodes::*; /// # use actix_web::httpcodes::*;
/// # /// #
/// use actix_web::headers::Cookie; /// use actix_web::header::Cookie;
/// use actix_web::client::ClientRequest; /// use actix_web::client::ClientRequest;
/// ///
/// fn main() { /// fn main() {

View file

@ -421,7 +421,7 @@ impl HttpResponseBuilder {
/// # use actix_web::*; /// # use actix_web::*;
/// # use actix_web::httpcodes::*; /// # use actix_web::httpcodes::*;
/// # /// #
/// use actix_web::headers::Cookie; /// use actix_web::header::Cookie;
/// ///
/// fn index(req: HttpRequest) -> Result<HttpResponse> { /// fn index(req: HttpRequest) -> Result<HttpResponse> {
/// Ok(HttpOk.build() /// Ok(HttpOk.build()

View file

@ -139,7 +139,7 @@ pub use application::Application;
pub use httpmessage::HttpMessage; pub use httpmessage::HttpMessage;
pub use httprequest::HttpRequest; pub use httprequest::HttpRequest;
pub use httpresponse::HttpResponse; pub use httpresponse::HttpResponse;
pub use handler::{Either, Responder, NormalizePath, AsyncResponder, FutureResponse}; pub use handler::{Either, Responder, AsyncResponder, FutureResponse};
pub use context::HttpContext; pub use context::HttpContext;
pub use server::HttpServer; pub use server::HttpServer;
pub use extractor::{Path, Query}; pub use extractor::{Path, Query};
@ -157,16 +157,6 @@ pub(crate) const HAS_TLS: bool = true;
#[cfg(not(feature="tls"))] #[cfg(not(feature="tls"))]
pub(crate) const HAS_TLS: bool = false; pub(crate) const HAS_TLS: bool = false;
#[doc(hidden)]
#[deprecated(since="0.4.4", note="please use `actix::header` module")]
pub mod headers {
//! Headers implementation
pub use httpresponse::ConnectionType;
pub use cookie::{Cookie, CookieBuilder};
pub use http_range::HttpRange;
pub use header::ContentEncoding;
}
pub mod helpers { pub mod helpers {
//! Various helpers //! Various helpers

View file

@ -10,7 +10,7 @@ use futures::unsync::oneshot;
use body::{Body, BodyStream}; use body::{Body, BodyStream};
use context::{Frame, ActorHttpContext}; use context::{Frame, ActorHttpContext};
use error::Error; use error::Error;
use headers::ContentEncoding; use header::ContentEncoding;
use handler::{Reply, ReplyItem}; use handler::{Reply, ReplyItem};
use httprequest::HttpRequest; use httprequest::HttpRequest;
use httpresponse::HttpResponse; use httpresponse::HttpResponse;

View file

@ -79,12 +79,6 @@ impl<S: 'static> Route<S> {
self self
} }
#[doc(hidden)]
#[deprecated(since="0.4.1", note="please use `.filter()` instead")]
pub fn p<T: Predicate<S> + 'static>(&mut self, p: T) -> &mut Self {
self.filter(p)
}
/// Set handler object. Usually call to this method is last call /// Set handler object. Usually call to this method is last call
/// during route configuration, so it does not return reference to self. /// during route configuration, so it does not return reference to self.
pub fn h<H: Handler<S>>(&mut self, handler: H) { pub fn h<H: Handler<S>>(&mut self, handler: H) {

View file

@ -9,7 +9,7 @@ use http::{Method, Version};
use http::header::{HeaderValue, CONNECTION, CONTENT_LENGTH, DATE}; use http::header::{HeaderValue, CONNECTION, CONTENT_LENGTH, DATE};
use body::{Body, Binary}; use body::{Body, Binary};
use headers::ContentEncoding; use header::ContentEncoding;
use httprequest::HttpInnerMessage; use httprequest::HttpInnerMessage;
use httpresponse::HttpResponse; use httpresponse::HttpResponse;
use super::helpers; use super::helpers;

View file

@ -10,7 +10,7 @@ use http::{Version, HttpTryFrom, Response};
use http::header::{HeaderValue, CONNECTION, TRANSFER_ENCODING, DATE, CONTENT_LENGTH}; use http::header::{HeaderValue, CONNECTION, TRANSFER_ENCODING, DATE, CONTENT_LENGTH};
use body::{Body, Binary}; use body::{Body, Binary};
use headers::ContentEncoding; use header::ContentEncoding;
use httprequest::HttpInnerMessage; use httprequest::HttpInnerMessage;
use httpresponse::HttpResponse; use httpresponse::HttpResponse;
use super::helpers; use super::helpers;

View file

@ -25,7 +25,7 @@ pub use self::settings::ServerSettings;
use body::Binary; use body::Binary;
use error::Error; use error::Error;
use headers::ContentEncoding; use header::ContentEncoding;
use httprequest::{HttpInnerMessage, HttpRequest}; use httprequest::{HttpInnerMessage, HttpRequest};
use httpresponse::HttpResponse; use httpresponse::HttpResponse;

View file

@ -133,48 +133,6 @@ impl TestServer {
} }
} }
#[deprecated(since="0.4.10",
note="please use `TestServer::build_with_state()` instead")]
/// Start new test server with custom application state
///
/// This method accepts state factory and configuration method.
pub fn with_state<S, FS, F>(state: FS, config: F) -> Self
where S: 'static,
FS: Sync + Send + 'static + Fn() -> S,
F: Sync + Send + 'static + Fn(&mut TestApp<S>),
{
let (tx, rx) = mpsc::channel();
// run server in separate thread
let join = thread::spawn(move || {
let sys = System::new("actix-test-server");
let tcp = net::TcpListener::bind("127.0.0.1:0").unwrap();
let local_addr = tcp.local_addr().unwrap();
let tcp = TcpListener::from_listener(tcp, &local_addr, Arbiter::handle()).unwrap();
HttpServer::new(move || {
let mut app = TestApp::new(state());
config(&mut app);
vec![app]}
).disable_signals().start_incoming(tcp.incoming(), false);
tx.send((Arbiter::system(), local_addr)).unwrap();
let _ = sys.run();
});
let system = System::new("actix-test");
let (server_sys, addr) = rx.recv().unwrap();
TestServer {
addr,
server_sys,
system,
ssl: false,
conn: TestServer::get_conn(),
thread: Some(join),
}
}
fn get_conn() -> Addr<Unsync, ClientConnector> { fn get_conn() -> Addr<Unsync, ClientConnector> {
#[cfg(feature="alpn")] #[cfg(feature="alpn")]
{ {

View file

@ -32,24 +32,6 @@ use super::frame::Frame;
use super::proto::{CloseCode, OpCode}; use super::proto::{CloseCode, OpCode};
/// Backward compatibility
#[doc(hidden)]
#[deprecated(since="0.4.2", note="please use `ws::Client` instead")]
pub type WsClient = Client;
#[doc(hidden)]
#[deprecated(since="0.4.2", note="please use `ws::ClientError` instead")]
pub type WsClientError = ClientError;
#[doc(hidden)]
#[deprecated(since="0.4.2", note="please use `ws::ClientReader` instead")]
pub type WsClientReader = ClientReader;
#[doc(hidden)]
#[deprecated(since="0.4.2", note="please use `ws::ClientWriter` instead")]
pub type WsClientWriter = ClientWriter;
#[doc(hidden)]
#[deprecated(since="0.4.2", note="please use `ws::ClientHandshake` instead")]
pub type WsClientHandshake = ClientHandshake;
/// Websocket client error /// Websocket client error
#[derive(Fail, Debug)] #[derive(Fail, Debug)]
pub enum ClientError { pub enum ClientError {

View file

@ -70,18 +70,6 @@ pub use self::context::WebsocketContext;
pub use self::client::{Client, ClientError, pub use self::client::{Client, ClientError,
ClientReader, ClientWriter, ClientHandshake}; ClientReader, ClientWriter, ClientHandshake};
#[allow(deprecated)]
pub use self::client::{WsClient, WsClientError,
WsClientReader, WsClientWriter, WsClientHandshake};
/// Backward compatibility
#[doc(hidden)]
#[deprecated(since="0.4.2", note="please use `ws::ProtocolError` instead")]
pub type WsError = ProtocolError;
#[doc(hidden)]
#[deprecated(since="0.4.2", note="please use `ws::HandshakeError` instead")]
pub type WsHandshakeError = HandshakeError;
/// Websocket protocol errors /// Websocket protocol errors
#[derive(Fail, Debug)] #[derive(Fail, Debug)]
pub enum ProtocolError { pub enum ProtocolError {

View file

@ -116,14 +116,14 @@ fn test_client_gzip_encoding() {
.and_then(|bytes: Bytes| { .and_then(|bytes: Bytes| {
Ok(httpcodes::HTTPOk Ok(httpcodes::HTTPOk
.build() .build()
.content_encoding(headers::ContentEncoding::Deflate) .content_encoding(header::ContentEncoding::Deflate)
.body(bytes)) .body(bytes))
}).responder()} }).responder()}
)); ));
// client request // client request
let request = srv.post() let request = srv.post()
.content_encoding(headers::ContentEncoding::Gzip) .content_encoding(header::ContentEncoding::Gzip)
.body(STR).unwrap(); .body(STR).unwrap();
let response = srv.execute(request.send()).unwrap(); let response = srv.execute(request.send()).unwrap();
assert!(response.status().is_success()); assert!(response.status().is_success());
@ -142,14 +142,14 @@ fn test_client_gzip_encoding_large() {
.and_then(|bytes: Bytes| { .and_then(|bytes: Bytes| {
Ok(httpcodes::HTTPOk Ok(httpcodes::HTTPOk
.build() .build()
.content_encoding(headers::ContentEncoding::Deflate) .content_encoding(header::ContentEncoding::Deflate)
.body(bytes)) .body(bytes))
}).responder()} }).responder()}
)); ));
// client request // client request
let request = srv.post() let request = srv.post()
.content_encoding(headers::ContentEncoding::Gzip) .content_encoding(header::ContentEncoding::Gzip)
.body(data.clone()).unwrap(); .body(data.clone()).unwrap();
let response = srv.execute(request.send()).unwrap(); let response = srv.execute(request.send()).unwrap();
assert!(response.status().is_success()); assert!(response.status().is_success());
@ -171,14 +171,14 @@ fn test_client_gzip_encoding_large_random() {
.and_then(|bytes: Bytes| { .and_then(|bytes: Bytes| {
Ok(httpcodes::HTTPOk Ok(httpcodes::HTTPOk
.build() .build()
.content_encoding(headers::ContentEncoding::Deflate) .content_encoding(header::ContentEncoding::Deflate)
.body(bytes)) .body(bytes))
}).responder()} }).responder()}
)); ));
// client request // client request
let request = srv.post() let request = srv.post()
.content_encoding(headers::ContentEncoding::Gzip) .content_encoding(header::ContentEncoding::Gzip)
.body(data.clone()).unwrap(); .body(data.clone()).unwrap();
let response = srv.execute(request.send()).unwrap(); let response = srv.execute(request.send()).unwrap();
assert!(response.status().is_success()); assert!(response.status().is_success());
@ -196,14 +196,14 @@ fn test_client_brotli_encoding() {
.and_then(|bytes: Bytes| { .and_then(|bytes: Bytes| {
Ok(httpcodes::HTTPOk Ok(httpcodes::HTTPOk
.build() .build()
.content_encoding(headers::ContentEncoding::Gzip) .content_encoding(header::ContentEncoding::Gzip)
.body(bytes)) .body(bytes))
}).responder()} }).responder()}
)); ));
// client request // client request
let request = srv.client(Method::POST, "/") let request = srv.client(Method::POST, "/")
.content_encoding(headers::ContentEncoding::Br) .content_encoding(header::ContentEncoding::Br)
.body(STR).unwrap(); .body(STR).unwrap();
let response = srv.execute(request.send()).unwrap(); let response = srv.execute(request.send()).unwrap();
assert!(response.status().is_success()); assert!(response.status().is_success());
@ -226,14 +226,14 @@ fn test_client_brotli_encoding_large_random() {
.and_then(move |bytes: Bytes| { .and_then(move |bytes: Bytes| {
Ok(httpcodes::HTTPOk Ok(httpcodes::HTTPOk
.build() .build()
.content_encoding(headers::ContentEncoding::Gzip) .content_encoding(header::ContentEncoding::Gzip)
.body(bytes)) .body(bytes))
}).responder()} }).responder()}
)); ));
// client request // client request
let request = srv.client(Method::POST, "/") let request = srv.client(Method::POST, "/")
.content_encoding(headers::ContentEncoding::Br) .content_encoding(header::ContentEncoding::Br)
.body(data.clone()).unwrap(); .body(data.clone()).unwrap();
let response = srv.execute(request.send()).unwrap(); let response = srv.execute(request.send()).unwrap();
assert!(response.status().is_success()); assert!(response.status().is_success());
@ -252,14 +252,14 @@ fn test_client_deflate_encoding() {
.and_then(|bytes: Bytes| { .and_then(|bytes: Bytes| {
Ok(httpcodes::HTTPOk Ok(httpcodes::HTTPOk
.build() .build()
.content_encoding(headers::ContentEncoding::Br) .content_encoding(header::ContentEncoding::Br)
.body(bytes)) .body(bytes))
}).responder()} }).responder()}
)); ));
// client request // client request
let request = srv.post() let request = srv.post()
.content_encoding(headers::ContentEncoding::Deflate) .content_encoding(header::ContentEncoding::Deflate)
.body(STR).unwrap(); .body(STR).unwrap();
let response = srv.execute(request.send()).unwrap(); let response = srv.execute(request.send()).unwrap();
assert!(response.status().is_success()); assert!(response.status().is_success());
@ -282,14 +282,14 @@ fn test_client_deflate_encoding_large_random() {
.and_then(|bytes: Bytes| { .and_then(|bytes: Bytes| {
Ok(httpcodes::HTTPOk Ok(httpcodes::HTTPOk
.build() .build()
.content_encoding(headers::ContentEncoding::Br) .content_encoding(header::ContentEncoding::Br)
.body(bytes)) .body(bytes))
}).responder()} }).responder()}
)); ));
// client request // client request
let request = srv.post() let request = srv.post()
.content_encoding(headers::ContentEncoding::Deflate) .content_encoding(header::ContentEncoding::Deflate)
.body(data.clone()).unwrap(); .body(data.clone()).unwrap();
let response = srv.execute(request.send()).unwrap(); let response = srv.execute(request.send()).unwrap();
assert!(response.status().is_success()); assert!(response.status().is_success());
@ -308,7 +308,7 @@ fn test_client_streaming_explicit() {
.and_then(|body| { .and_then(|body| {
Ok(httpcodes::HTTPOk.build() Ok(httpcodes::HTTPOk.build()
.chunked() .chunked()
.content_encoding(headers::ContentEncoding::Identity) .content_encoding(header::ContentEncoding::Identity)
.body(body)?)}) .body(body)?)})
.responder())); .responder()));
@ -329,7 +329,7 @@ fn test_body_streaming_implicit() {
|app| app.handler(|_| { |app| app.handler(|_| {
let body = once(Ok(Bytes::from_static(STR.as_ref()))); let body = once(Ok(Bytes::from_static(STR.as_ref())));
httpcodes::HTTPOk.build() httpcodes::HTTPOk.build()
.content_encoding(headers::ContentEncoding::Gzip) .content_encoding(header::ContentEncoding::Gzip)
.body(Body::Streaming(Box::new(body)))})); .body(Body::Streaming(Box::new(body)))}));
let request = srv.get().finish().unwrap(); let request = srv.get().finish().unwrap();

View file

@ -24,7 +24,7 @@ use futures::{Future, Stream};
use futures::stream::once; use futures::stream::once;
use h2::client as h2client; use h2::client as h2client;
use bytes::{Bytes, BytesMut}; use bytes::{Bytes, BytesMut};
use http::{header, Request}; use http::Request;
use tokio_core::net::TcpStream; use tokio_core::net::TcpStream;
use tokio_core::reactor::Core; use tokio_core::reactor::Core;
use rand::Rng; use rand::Rng;
@ -196,7 +196,7 @@ fn test_body_gzip() {
let mut srv = test::TestServer::new( let mut srv = test::TestServer::new(
|app| app.handler( |app| app.handler(
|_| httpcodes::HTTPOk.build() |_| httpcodes::HTTPOk.build()
.content_encoding(headers::ContentEncoding::Gzip) .content_encoding(header::ContentEncoding::Gzip)
.body(STR))); .body(STR)));
let request = srv.get().disable_decompress().finish().unwrap(); let request = srv.get().disable_decompress().finish().unwrap();
@ -223,7 +223,7 @@ fn test_body_gzip_large() {
let data = srv_data.clone(); let data = srv_data.clone();
app.handler( app.handler(
move |_| httpcodes::HTTPOk.build() move |_| httpcodes::HTTPOk.build()
.content_encoding(headers::ContentEncoding::Gzip) .content_encoding(header::ContentEncoding::Gzip)
.body(data.as_ref()))}); .body(data.as_ref()))});
let request = srv.get().disable_decompress().finish().unwrap(); let request = srv.get().disable_decompress().finish().unwrap();
@ -253,7 +253,7 @@ fn test_body_gzip_large_random() {
let data = srv_data.clone(); let data = srv_data.clone();
app.handler( app.handler(
move |_| httpcodes::HTTPOk.build() move |_| httpcodes::HTTPOk.build()
.content_encoding(headers::ContentEncoding::Gzip) .content_encoding(header::ContentEncoding::Gzip)
.body(data.as_ref()))}); .body(data.as_ref()))});
let request = srv.get().disable_decompress().finish().unwrap(); let request = srv.get().disable_decompress().finish().unwrap();
@ -277,7 +277,7 @@ fn test_body_chunked_implicit() {
|app| app.handler(|_| { |app| app.handler(|_| {
let body = once(Ok(Bytes::from_static(STR.as_ref()))); let body = once(Ok(Bytes::from_static(STR.as_ref())));
httpcodes::HTTPOk.build() httpcodes::HTTPOk.build()
.content_encoding(headers::ContentEncoding::Gzip) .content_encoding(header::ContentEncoding::Gzip)
.body(Body::Streaming(Box::new(body)))})); .body(Body::Streaming(Box::new(body)))}));
let request = srv.get().disable_decompress().finish().unwrap(); let request = srv.get().disable_decompress().finish().unwrap();
@ -301,7 +301,7 @@ fn test_body_br_streaming() {
|app| app.handler(|_| { |app| app.handler(|_| {
let body = once(Ok(Bytes::from_static(STR.as_ref()))); let body = once(Ok(Bytes::from_static(STR.as_ref())));
httpcodes::HTTPOk.build() httpcodes::HTTPOk.build()
.content_encoding(headers::ContentEncoding::Br) .content_encoding(header::ContentEncoding::Br)
.body(Body::Streaming(Box::new(body)))})); .body(Body::Streaming(Box::new(body)))}));
let request = srv.get().disable_decompress().finish().unwrap(); let request = srv.get().disable_decompress().finish().unwrap();
@ -330,7 +330,7 @@ fn test_head_empty() {
assert!(response.status().is_success()); assert!(response.status().is_success());
{ {
let len = response.headers().get(header::CONTENT_LENGTH).unwrap(); let len = response.headers().get(header::http::CONTENT_LENGTH).unwrap();
assert_eq!(format!("{}", STR.len()), len.to_str().unwrap()); assert_eq!(format!("{}", STR.len()), len.to_str().unwrap());
} }
@ -344,7 +344,7 @@ fn test_head_binary() {
let mut srv = test::TestServer::new( let mut srv = test::TestServer::new(
|app| app.handler(|_| { |app| app.handler(|_| {
httpcodes::HTTPOk.build() httpcodes::HTTPOk.build()
.content_encoding(headers::ContentEncoding::Identity) .content_encoding(header::ContentEncoding::Identity)
.content_length(100).body(STR)})); .content_length(100).body(STR)}));
let request = srv.head().finish().unwrap(); let request = srv.head().finish().unwrap();
@ -352,7 +352,7 @@ fn test_head_binary() {
assert!(response.status().is_success()); assert!(response.status().is_success());
{ {
let len = response.headers().get(header::CONTENT_LENGTH).unwrap(); let len = response.headers().get(header::http::CONTENT_LENGTH).unwrap();
assert_eq!(format!("{}", STR.len()), len.to_str().unwrap()); assert_eq!(format!("{}", STR.len()), len.to_str().unwrap());
} }
@ -366,7 +366,7 @@ fn test_head_binary2() {
let mut srv = test::TestServer::new( let mut srv = test::TestServer::new(
|app| app.handler(|_| { |app| app.handler(|_| {
httpcodes::HTTPOk.build() httpcodes::HTTPOk.build()
.content_encoding(headers::ContentEncoding::Identity) .content_encoding(header::ContentEncoding::Identity)
.body(STR) .body(STR)
})); }));
@ -375,7 +375,7 @@ fn test_head_binary2() {
assert!(response.status().is_success()); assert!(response.status().is_success());
{ {
let len = response.headers().get(header::CONTENT_LENGTH).unwrap(); let len = response.headers().get(header::http::CONTENT_LENGTH).unwrap();
assert_eq!(format!("{}", STR.len()), len.to_str().unwrap()); assert_eq!(format!("{}", STR.len()), len.to_str().unwrap());
} }
} }
@ -387,7 +387,7 @@ fn test_body_length() {
let body = once(Ok(Bytes::from_static(STR.as_ref()))); let body = once(Ok(Bytes::from_static(STR.as_ref())));
httpcodes::HTTPOk.build() httpcodes::HTTPOk.build()
.content_length(STR.len() as u64) .content_length(STR.len() as u64)
.content_encoding(headers::ContentEncoding::Identity) .content_encoding(header::ContentEncoding::Identity)
.body(Body::Streaming(Box::new(body)))})); .body(Body::Streaming(Box::new(body)))}));
let request = srv.get().finish().unwrap(); let request = srv.get().finish().unwrap();
@ -406,7 +406,7 @@ fn test_body_chunked_explicit() {
let body = once(Ok(Bytes::from_static(STR.as_ref()))); let body = once(Ok(Bytes::from_static(STR.as_ref())));
httpcodes::HTTPOk.build() httpcodes::HTTPOk.build()
.chunked() .chunked()
.content_encoding(headers::ContentEncoding::Gzip) .content_encoding(header::ContentEncoding::Gzip)
.body(Body::Streaming(Box::new(body)))})); .body(Body::Streaming(Box::new(body)))}));
let request = srv.get().disable_decompress().finish().unwrap(); let request = srv.get().disable_decompress().finish().unwrap();
@ -429,7 +429,7 @@ fn test_body_deflate() {
|app| app.handler( |app| app.handler(
|_| httpcodes::HTTPOk |_| httpcodes::HTTPOk
.build() .build()
.content_encoding(headers::ContentEncoding::Deflate) .content_encoding(header::ContentEncoding::Deflate)
.body(STR))); .body(STR)));
// client request // client request
@ -454,7 +454,7 @@ fn test_body_brotli() {
|app| app.handler( |app| app.handler(
|_| httpcodes::HTTPOk |_| httpcodes::HTTPOk
.build() .build()
.content_encoding(headers::ContentEncoding::Br) .content_encoding(header::ContentEncoding::Br)
.body(STR))); .body(STR)));
// client request // client request
@ -479,7 +479,7 @@ fn test_gzip_encoding() {
.and_then(|bytes: Bytes| { .and_then(|bytes: Bytes| {
Ok(httpcodes::HTTPOk Ok(httpcodes::HTTPOk
.build() .build()
.content_encoding(headers::ContentEncoding::Identity) .content_encoding(header::ContentEncoding::Identity)
.body(bytes)) .body(bytes))
}).responder()} }).responder()}
)); ));
@ -490,7 +490,7 @@ fn test_gzip_encoding() {
let enc = e.finish().unwrap(); let enc = e.finish().unwrap();
let request = srv.post() let request = srv.post()
.header(header::CONTENT_ENCODING, "gzip") .header(header::http::CONTENT_ENCODING, "gzip")
.body(enc.clone()).unwrap(); .body(enc.clone()).unwrap();
let response = srv.execute(request.send()).unwrap(); let response = srv.execute(request.send()).unwrap();
assert!(response.status().is_success()); assert!(response.status().is_success());
@ -508,7 +508,7 @@ fn test_gzip_encoding_large() {
.and_then(|bytes: Bytes| { .and_then(|bytes: Bytes| {
Ok(httpcodes::HTTPOk Ok(httpcodes::HTTPOk
.build() .build()
.content_encoding(headers::ContentEncoding::Identity) .content_encoding(header::ContentEncoding::Identity)
.body(bytes)) .body(bytes))
}).responder()} }).responder()}
)); ));
@ -519,7 +519,7 @@ fn test_gzip_encoding_large() {
let enc = e.finish().unwrap(); let enc = e.finish().unwrap();
let request = srv.post() let request = srv.post()
.header(header::CONTENT_ENCODING, "gzip") .header(header::http::CONTENT_ENCODING, "gzip")
.body(enc.clone()).unwrap(); .body(enc.clone()).unwrap();
let response = srv.execute(request.send()).unwrap(); let response = srv.execute(request.send()).unwrap();
assert!(response.status().is_success()); assert!(response.status().is_success());
@ -541,7 +541,7 @@ fn test_reading_gzip_encoding_large_random() {
.and_then(|bytes: Bytes| { .and_then(|bytes: Bytes| {
Ok(httpcodes::HTTPOk Ok(httpcodes::HTTPOk
.build() .build()
.content_encoding(headers::ContentEncoding::Identity) .content_encoding(header::ContentEncoding::Identity)
.body(bytes)) .body(bytes))
}).responder()} }).responder()}
)); ));
@ -552,7 +552,7 @@ fn test_reading_gzip_encoding_large_random() {
let enc = e.finish().unwrap(); let enc = e.finish().unwrap();
let request = srv.post() let request = srv.post()
.header(header::CONTENT_ENCODING, "gzip") .header(header::http::CONTENT_ENCODING, "gzip")
.body(enc.clone()).unwrap(); .body(enc.clone()).unwrap();
let response = srv.execute(request.send()).unwrap(); let response = srv.execute(request.send()).unwrap();
assert!(response.status().is_success()); assert!(response.status().is_success());
@ -570,7 +570,7 @@ fn test_reading_deflate_encoding() {
.and_then(|bytes: Bytes| { .and_then(|bytes: Bytes| {
Ok(httpcodes::HTTPOk Ok(httpcodes::HTTPOk
.build() .build()
.content_encoding(headers::ContentEncoding::Identity) .content_encoding(header::ContentEncoding::Identity)
.body(bytes)) .body(bytes))
}).responder()} }).responder()}
)); ));
@ -581,7 +581,7 @@ fn test_reading_deflate_encoding() {
// client request // client request
let request = srv.post() let request = srv.post()
.header(header::CONTENT_ENCODING, "deflate") .header(header::http::CONTENT_ENCODING, "deflate")
.body(enc).unwrap(); .body(enc).unwrap();
let response = srv.execute(request.send()).unwrap(); let response = srv.execute(request.send()).unwrap();
assert!(response.status().is_success()); assert!(response.status().is_success());
@ -599,7 +599,7 @@ fn test_reading_deflate_encoding_large() {
.and_then(|bytes: Bytes| { .and_then(|bytes: Bytes| {
Ok(httpcodes::HTTPOk Ok(httpcodes::HTTPOk
.build() .build()
.content_encoding(headers::ContentEncoding::Identity) .content_encoding(header::ContentEncoding::Identity)
.body(bytes)) .body(bytes))
}).responder()} }).responder()}
)); ));
@ -610,7 +610,7 @@ fn test_reading_deflate_encoding_large() {
// client request // client request
let request = srv.post() let request = srv.post()
.header(header::CONTENT_ENCODING, "deflate") .header(header::http::CONTENT_ENCODING, "deflate")
.body(enc).unwrap(); .body(enc).unwrap();
let response = srv.execute(request.send()).unwrap(); let response = srv.execute(request.send()).unwrap();
assert!(response.status().is_success()); assert!(response.status().is_success());
@ -632,7 +632,7 @@ fn test_reading_deflate_encoding_large_random() {
.and_then(|bytes: Bytes| { .and_then(|bytes: Bytes| {
Ok(httpcodes::HTTPOk Ok(httpcodes::HTTPOk
.build() .build()
.content_encoding(headers::ContentEncoding::Identity) .content_encoding(header::ContentEncoding::Identity)
.body(bytes)) .body(bytes))
}).responder()} }).responder()}
)); ));
@ -643,7 +643,7 @@ fn test_reading_deflate_encoding_large_random() {
// client request // client request
let request = srv.post() let request = srv.post()
.header(header::CONTENT_ENCODING, "deflate") .header(header::http::CONTENT_ENCODING, "deflate")
.body(enc).unwrap(); .body(enc).unwrap();
let response = srv.execute(request.send()).unwrap(); let response = srv.execute(request.send()).unwrap();
assert!(response.status().is_success()); assert!(response.status().is_success());
@ -662,7 +662,7 @@ fn test_brotli_encoding() {
.and_then(|bytes: Bytes| { .and_then(|bytes: Bytes| {
Ok(httpcodes::HTTPOk Ok(httpcodes::HTTPOk
.build() .build()
.content_encoding(headers::ContentEncoding::Identity) .content_encoding(header::ContentEncoding::Identity)
.body(bytes)) .body(bytes))
}).responder()} }).responder()}
)); ));
@ -673,7 +673,7 @@ fn test_brotli_encoding() {
// client request // client request
let request = srv.post() let request = srv.post()
.header(header::CONTENT_ENCODING, "br") .header(header::http::CONTENT_ENCODING, "br")
.body(enc).unwrap(); .body(enc).unwrap();
let response = srv.execute(request.send()).unwrap(); let response = srv.execute(request.send()).unwrap();
assert!(response.status().is_success()); assert!(response.status().is_success());
@ -692,7 +692,7 @@ fn test_brotli_encoding_large() {
.and_then(|bytes: Bytes| { .and_then(|bytes: Bytes| {
Ok(httpcodes::HTTPOk Ok(httpcodes::HTTPOk
.build() .build()
.content_encoding(headers::ContentEncoding::Identity) .content_encoding(header::ContentEncoding::Identity)
.body(bytes)) .body(bytes))
}).responder()} }).responder()}
)); ));
@ -703,7 +703,7 @@ fn test_brotli_encoding_large() {
// client request // client request
let request = srv.post() let request = srv.post()
.header(header::CONTENT_ENCODING, "br") .header(header::http::CONTENT_ENCODING, "br")
.body(enc).unwrap(); .body(enc).unwrap();
let response = srv.execute(request.send()).unwrap(); let response = srv.execute(request.send()).unwrap();
assert!(response.status().is_success()); assert!(response.status().is_success());