diff --git a/Cargo.toml b/Cargo.toml index 2a9883ea..44262e84 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,6 +28,7 @@ path = "src/lib.rs" members = [ ".", "awc", + "actix-http", "actix-files", "actix-session", "actix-web-actors", @@ -71,7 +72,7 @@ actix-utils = "0.3.4" actix-router = "0.1.0" actix-rt = "0.2.1" actix-web-codegen = { path="actix-web-codegen" } -actix-http = { git = "https://github.com/actix/actix-http.git", features=["fail"] } +actix-http = { path = "actix-http", features=["fail"] } actix-server = "0.4.1" actix-server-config = "0.1.0" awc = { path = "awc", optional = true } @@ -105,8 +106,8 @@ openssl = { version="0.10", optional = true } # rustls = { version = "^0.15", optional = true } [dev-dependencies] -actix-http = { git = "https://github.com/actix/actix-http.git", features=["ssl"] } -actix-http-test = { git = "https://github.com/actix/actix-http.git", features=["ssl"] } +actix-http = { path = "actix-http", features=["ssl"] } +actix-http-test = { path = "actix-http/test-server", features=["ssl"] } rand = "0.6" env_logger = "0.6" serde_derive = "1.0" diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index da11a585..798508a9 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -14,6 +14,7 @@ categories = ["network-programming", "asynchronous", license = "MIT/Apache-2.0" exclude = [".gitignore", ".travis.yml", ".cargo/config", "appveyor.yml"] edition = "2018" +workspace = ".." [package.metadata.docs.rs] features = ["ssl", "fail", "cookie"] diff --git a/actix-http/test-server/Cargo.toml b/actix-http/test-server/Cargo.toml index 313bc55c..316f3e36 100644 --- a/actix-http/test-server/Cargo.toml +++ b/actix-http/test-server/Cargo.toml @@ -38,7 +38,7 @@ actix-http = { path=".." } actix-service = "0.3.4" actix-server = "0.4.0" actix-utils = "0.3.4" -awc = { git = "https://github.com/actix/actix-web.git" } +awc = { path = "../../awc" } base64 = "0.10" bytes = "0.4" diff --git a/awc/Cargo.toml b/awc/Cargo.toml index b43a8d47..233fe59d 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -28,7 +28,7 @@ cookies = ["cookie", "actix-http/cookies"] [dependencies] actix-service = "0.3.4" -actix-http = { git = "https://github.com/actix/actix-http.git" } +actix-http = { path = "../actix-http/" } bytes = "0.4" futures = "0.1" log =" 0.4" @@ -44,5 +44,5 @@ openssl = { version="0.10", optional = true } env_logger = "0.6" mime = "0.3" actix-rt = "0.2.1" -actix-http = { git = "https://github.com/actix/actix-http.git", features=["ssl"] } -actix-http-test = { git = "https://github.com/actix/actix-http.git", features=["ssl"] } +actix-http = { path = "../actix-http/", features=["ssl"] } +actix-http-test = { path = "../actix-http/test-server/", features=["ssl"] } diff --git a/actix-http/examples/client.rs b/examples/client.rs similarity index 74% rename from actix-http/examples/client.rs rename to examples/client.rs index 7f5f8c91..c4df6f7d 100644 --- a/actix-http/examples/client.rs +++ b/examples/client.rs @@ -1,4 +1,4 @@ -use actix_http::{client, Error}; +use actix_http::Error; use actix_rt::System; use bytes::BytesMut; use futures::{future::lazy, Future, Stream}; @@ -8,13 +8,10 @@ fn main() -> Result<(), Error> { env_logger::init(); System::new("test").block_on(lazy(|| { - let mut connector = client::Connector::new().service(); - - client::ClientRequest::get("https://www.rust-lang.org/") // <- Create request builder + awc::Client::new() + .get("https://www.rust-lang.org/") // <- Create request builder .header("User-Agent", "Actix-web") - .finish() - .unwrap() - .send(&mut connector) // <- Send http request + .send() // <- Send http request .from_err() .and_then(|response| { // <- server http response diff --git a/tests/test_httpserver.rs b/tests/test_httpserver.rs index 764d50ca..4a3850f1 100644 --- a/tests/test_httpserver.rs +++ b/tests/test_httpserver.rs @@ -48,23 +48,21 @@ fn test_start() { }); let (srv, sys) = rx.recv().unwrap(); - let mut connector = test::run_on(|| { + let client = test::run_on(|| { Ok::<_, ()>( - client::Connector::new() - .timeout(Duration::from_millis(100)) - .service(), + awc::Client::build() + .connector( + client::Connector::new() + .timeout(Duration::from_millis(100)) + .service(), + ) + .finish(), ) }) .unwrap(); let host = format!("http://{}", addr); - let response = test::block_on( - client::ClientRequest::get(host.clone()) - .finish() - .unwrap() - .send(&mut connector), - ) - .unwrap(); + let response = test::block_on(client.get(host.clone()).send()).unwrap(); assert!(response.status().is_success()); // stop diff --git a/tests/test_server.rs b/tests/test_server.rs index 2742164a..9c0f1f65 100644 --- a/tests/test_server.rs +++ b/tests/test_server.rs @@ -45,8 +45,7 @@ fn test_body() { ) }); - let request = srv.get().finish().unwrap(); - let mut response = srv.send_request(request).unwrap(); + let mut response = srv.block_on(srv.get().send()).unwrap(); assert!(response.status().is_success()); // read response @@ -64,8 +63,7 @@ fn test_body_gzip() { ) }); - let request = srv.get().finish().unwrap(); - let mut response = srv.send_request(request).unwrap(); + let mut response = srv.block_on(srv.get().send()).unwrap(); assert!(response.status().is_success()); // read response @@ -95,8 +93,7 @@ fn test_body_gzip_large() { ) }); - let request = srv.get().finish().unwrap(); - let mut response = srv.send_request(request).unwrap(); + let mut response = srv.block_on(srv.get().send()).unwrap(); assert!(response.status().is_success()); // read response @@ -129,8 +126,7 @@ fn test_body_gzip_large_random() { ) }); - let request = srv.get().finish().unwrap(); - let mut response = srv.send_request(request).unwrap(); + let mut response = srv.block_on(srv.get().send()).unwrap(); assert!(response.status().is_success()); // read response @@ -158,8 +154,7 @@ fn test_body_chunked_implicit() { ) }); - let request = srv.get().finish().unwrap(); - let mut response = srv.send_request(request).unwrap(); + let mut response = srv.block_on(srv.get().send()).unwrap(); assert!(response.status().is_success()); assert_eq!( response.headers().get(TRANSFER_ENCODING).unwrap(), @@ -190,8 +185,9 @@ fn test_body_br_streaming() { ) }); - let request = srv.get().header(ACCEPT_ENCODING, "br").finish().unwrap(); - let mut response = srv.send_request(request).unwrap(); + let mut response = srv + .block_on(srv.get().header(ACCEPT_ENCODING, "br").send()) + .unwrap(); assert!(response.status().is_success()); // read response @@ -212,8 +208,7 @@ fn test_head_binary() { ))) }); - let request = srv.head().finish().unwrap(); - let mut response = srv.send_request(request).unwrap(); + let mut response = srv.block_on(srv.head().send()).unwrap(); assert!(response.status().is_success()); { @@ -239,8 +234,7 @@ fn test_no_chunking() { )))) }); - let request = srv.get().finish().unwrap(); - let mut response = srv.send_request(request).unwrap(); + let mut response = srv.block_on(srv.get().send()).unwrap(); assert!(response.status().is_success()); assert!(!response.headers().contains_key(TRANSFER_ENCODING)); @@ -262,8 +256,7 @@ fn test_body_deflate() { }); // client request - let request = srv.get().finish().unwrap(); - let mut response = srv.send_request(request).unwrap(); + let mut response = srv.block_on(srv.get().send()).unwrap(); assert!(response.status().is_success()); // read response @@ -289,8 +282,9 @@ fn test_body_brotli() { }); // client request - let request = srv.get().header(ACCEPT_ENCODING, "br").finish().unwrap(); - let mut response = srv.send_request(request).unwrap(); + let mut response = srv + .block_on(srv.get().header(ACCEPT_ENCODING, "br").send()) + .unwrap(); assert!(response.status().is_success()); // read response