mirror of
https://github.com/actix/actix-web.git
synced 2024-11-26 03:21:08 +00:00
add rustls support to HttpServer
This commit is contained in:
parent
e9bbde6832
commit
c126713f40
9 changed files with 234 additions and 226 deletions
|
@ -35,7 +35,7 @@ members = [
|
|||
]
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
features = ["ssl", "tls", "brotli", "flate2-zlib", "cookies", "client"]
|
||||
features = ["ssl", "tls", "brotli", "flate2-zlib", "cookies", "client", "rust-tls"]
|
||||
|
||||
[features]
|
||||
default = ["brotli", "flate2-zlib", "cookies", "client"]
|
||||
|
@ -62,7 +62,7 @@ tls = ["native-tls", "actix-server/ssl"]
|
|||
ssl = ["openssl", "actix-server/ssl", "awc/ssl"]
|
||||
|
||||
# rustls
|
||||
# rust-tls = ["rustls", "actix-server/rustls"]
|
||||
rust-tls = ["rustls", "actix-server/rust-tls"]
|
||||
|
||||
[dependencies]
|
||||
actix-codec = "0.1.1"
|
||||
|
@ -100,7 +100,7 @@ cookie = { version="0.11", features=["secure", "percent-encode"], optional = tru
|
|||
# ssl support
|
||||
native-tls = { version="0.2", optional = true }
|
||||
openssl = { version="0.10", optional = true }
|
||||
# rustls = { version = "^0.15", optional = true }
|
||||
rustls = { version = "^0.15", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
actix-http = { path = "actix-http", features=["ssl", "brotli", "flate2-zlib"] }
|
||||
|
@ -112,6 +112,9 @@ tokio-timer = "0.2.8"
|
|||
brotli2 = "0.3.2"
|
||||
flate2 = "1.0.2"
|
||||
|
||||
[replace]
|
||||
"cookie:0.11.0" = { git = 'https://github.com/alexcrichton/cookie-rs.git' }
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
opt-level = 3
|
||||
|
|
|
@ -10,7 +10,7 @@ Actix web is a simple, pragmatic and extremely fast web framework for Rust.
|
|||
* Configurable [request routing](https://actix.rs/docs/url-dispatch/)
|
||||
* Multipart streams
|
||||
* Static assets
|
||||
* SSL support with OpenSSL or native-tls
|
||||
* SSL support with OpenSSL or Rustls
|
||||
* Middlewares ([Logger, Session, CORS, CSRF, etc](https://actix.rs/docs/middleware/))
|
||||
* Includes an asynchronous [HTTP client](https://actix.rs/actix-web/actix_web/client/index.html)
|
||||
* Supports [Actix actor framework](https://github.com/actix/actix)
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
-----BEGIN CERTIFICATE-----
|
||||
MIICljCCAX4CCQDFdWu66640QjANBgkqhkiG9w0BAQsFADANMQswCQYDVQQGEwJ1
|
||||
czAeFw0xOTAyMDQyMzEyNTBaFw0yMDAyMDQyMzEyNTBaMA0xCzAJBgNVBAYTAnVz
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzZUXMnS5X8HWxTvHAc82
|
||||
Q2d32fiPQGtD+fp3OV90l6RC9jgMdH4yTVUgX5mYYcW0k89RaP8g61H6b76F9gcd
|
||||
yZ1idqKI1AU9aeBUPV8wkrouhR/6Omv8fA7yr9tVmNo53jPN7WyKoBoU0r7Yj9Ez
|
||||
g3qjv/808Jlgby3EhduruyyfdvSt5ZFXnOz2D3SF9DS4yrM2jSw4ZTuoVMfZ8vZe
|
||||
FVzLo/+sV8qokU6wBTEOAmZQ7e/zZV4qAoH2Z3Vj/uD1Zr/MXYyh81RdXpDqIXwV
|
||||
Z29LEOa2eTGFEdvfG+tdvvuIvSdF3+WbLrwn2ECfwJ8zmKyTauPRV4pj7ks+wkBI
|
||||
EQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQB6dmuWBOpFfDdu0mdsDb8XnJY1svjH
|
||||
4kbztXhjQJ/WuhCUIwvXFyz9dqQCq+TbJUbUEzZJEfaq1uaI3iB5wd35ArSoAGJA
|
||||
k0lonzyeSM+cmNOe/5BPqWhd1qPwbsfgMoCCkZUoTT5Rvw6yt00XIqZzMqrsvRBX
|
||||
hAcUW3zBtFQNP6aQqsMdn4ClZE0WHf+LzWy2NQh+Sf46tSYBHELfdUawgR789PB4
|
||||
/gNjAeklq06JmE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8V9ZM72gJhDN
|
||||
8D/lXduTZ9JMwLOa1NUB8/I6CbaU3VzWkfodArKKpQF3M+LLgK03i12PD0KPQ5zv
|
||||
bwaNoQo6cTmPNIdsVZETRvPqONiCUaQV57G74dGtjeirCh/DO5EYRtb1thgS7TGm
|
||||
+Xg8OC5vZ6g0+xsrSqDBmWNtlI7S3bsL5C3LIEOOAL1ZJHRy2KvIGQ9ipb3XjnKS
|
||||
N7/wlQduRyPH7oaD/o4xf5Gt
|
||||
-----END CERTIFICATE-----
|
||||
|
|
Binary file not shown.
|
@ -1,28 +1,27 @@
|
|||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDNlRcydLlfwdbF
|
||||
O8cBzzZDZ3fZ+I9Aa0P5+nc5X3SXpEL2OAx0fjJNVSBfmZhhxbSTz1Fo/yDrUfpv
|
||||
voX2Bx3JnWJ2oojUBT1p4FQ9XzCSui6FH/o6a/x8DvKv21WY2jneM83tbIqgGhTS
|
||||
vtiP0TODeqO//zTwmWBvLcSF26u7LJ929K3lkVec7PYPdIX0NLjKszaNLDhlO6hU
|
||||
x9ny9l4VXMuj/6xXyqiRTrAFMQ4CZlDt7/NlXioCgfZndWP+4PVmv8xdjKHzVF1e
|
||||
kOohfBVnb0sQ5rZ5MYUR298b612++4i9J0Xf5ZsuvCfYQJ/AnzOYrJNq49FXimPu
|
||||
Sz7CQEgRAgMBAAECggEBALC547EaKmko5wmyM4dYq9sRzTPxuqO0EkGIkIkfh8j8
|
||||
ChxDXmGeQnu8HBJSpW4XWP5fkCpkd9YTKOh6rgorX+37f7NgUaOBxaOIlqITfFwF
|
||||
9Qu3y5IBVpEHAJUwRcsaffiILBRX5GtxQElSijRHsLLr8GySZN4X25B3laNEjcJe
|
||||
NWJrDaxOn0m0MMGRvBpM8PaZu1Mn9NWxt04b/fteVLdN4TAcuY9TgvVZBq92S2FM
|
||||
qvZcnJCQckNOuMOptVdP45qPker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0TP0yF
|
||||
0748CKw1A+ITbTVFV+vKvi4jzIxS7mr4wYtVCMssbttQN7y3l30IDxJwa9j3zTJx
|
||||
IUn5OMMLv1JyitLId8HdOy1AdU3MkpJzdLyi1mFfAoGBAL3kL4fGABM/kU7SN6RO
|
||||
zgS0AvdrYOeljBp1BRGg2hab58g02vamxVEZgqMTR7zwjPDqOIz+03U7wda4Ccyd
|
||||
PUhDNJSB/r6xNepshZZi642eLlnCRguqjYyNw72QADtYv2B6uehAlXEUY8xtw0lW
|
||||
OGgcSeyF2pH6M3tswWNlgT3lAoGAQ/BttBelOnP7NKgTLH7Usc4wjyAIaszpePZn
|
||||
Ykw6dLBP0oixzoCZ7seRYSOgJWkVcEz39Db+KP60mVWTvbIjMHm+vOVy+Pip0JQM
|
||||
xXQwKWU3ZNZSrzPkyWW55ejYQn9nIn5T5mxH3ojBXHcJ9Y8RLQ20zKzwrI77zE3i
|
||||
mqGK9NkCgYEAq3dzHI0DGAJrR19sWl2LcqI19sj5a91tHx4cl1dJXS/iApOLLieU
|
||||
zyUGkwfsqjHPAZ7GacICeBojIn/7KdPdlSKAbGVAU3d4qzvFS0qmWzObplBz3niT
|
||||
Xnep2XLaVXqwlFJZZ6AHeKzYmMH0d0raiou2bpEUBqYizy2fi3NI4mA=
|
||||
-----END RSA PRIVATE KEY-----
|
||||
|
|
101
src/server.rs
101
src/server.rs
|
@ -11,11 +11,10 @@ use parking_lot::Mutex;
|
|||
|
||||
use net2::TcpBuilder;
|
||||
|
||||
// #[cfg(feature = "tls")]
|
||||
// use native_tls::TlsAcceptor;
|
||||
|
||||
#[cfg(feature = "ssl")]
|
||||
use openssl::ssl::{SslAcceptor, SslAcceptorBuilder};
|
||||
#[cfg(feature = "rust-tls")]
|
||||
use rustls::ServerConfig as RustlsServerConfig;
|
||||
|
||||
struct Socket {
|
||||
scheme: &'static str,
|
||||
|
@ -254,19 +253,6 @@ where
|
|||
Ok(self)
|
||||
}
|
||||
|
||||
// #[cfg(feature = "tls")]
|
||||
// /// Use listener for accepting incoming tls connection requests
|
||||
// ///
|
||||
// /// HttpServer does not change any configuration for TcpListener,
|
||||
// /// it needs to be configured before passing it to listen() method.
|
||||
// pub fn listen_nativetls(self, lst: net::TcpListener, acceptor: TlsAcceptor) -> Self {
|
||||
// use actix_server::ssl;
|
||||
|
||||
// self.listen_with(lst, move || {
|
||||
// ssl::NativeTlsAcceptor::new(acceptor.clone()).map_err(|_| ())
|
||||
// })
|
||||
// }
|
||||
|
||||
#[cfg(feature = "ssl")]
|
||||
/// Use listener for accepting incoming tls connection requests
|
||||
///
|
||||
|
@ -294,7 +280,7 @@ where
|
|||
let addr = lst.local_addr().unwrap();
|
||||
self.sockets.push(Socket {
|
||||
addr,
|
||||
scheme: "http",
|
||||
scheme: "https",
|
||||
});
|
||||
|
||||
self.builder = Some(self.builder.take().unwrap().listen(
|
||||
|
@ -320,12 +306,52 @@ where
|
|||
/// Use listener for accepting incoming tls connection requests
|
||||
///
|
||||
/// This method sets alpn protocols to "h2" and "http/1.1"
|
||||
pub fn listen_rustls(self, lst: net::TcpListener, config: ServerConfig) -> Self {
|
||||
use super::{RustlsAcceptor, ServerFlags};
|
||||
pub fn listen_rustls(
|
||||
mut self,
|
||||
lst: net::TcpListener,
|
||||
config: RustlsServerConfig,
|
||||
) -> io::Result<Self> {
|
||||
self.listen_rustls_inner(lst, config)?;
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
self.listen_with(lst, move || {
|
||||
RustlsAcceptor::with_flags(config.clone(), flags).map_err(|_| ())
|
||||
})
|
||||
#[cfg(feature = "rust-tls")]
|
||||
fn listen_rustls_inner(
|
||||
&mut self,
|
||||
lst: net::TcpListener,
|
||||
mut config: RustlsServerConfig,
|
||||
) -> io::Result<()> {
|
||||
use actix_server::ssl::{RustlsAcceptor, SslError};
|
||||
|
||||
let protos = vec!["h2".to_string().into(), "http/1.1".to_string().into()];
|
||||
config.set_protocols(&protos);
|
||||
|
||||
let acceptor = RustlsAcceptor::new(config);
|
||||
let factory = self.factory.clone();
|
||||
let cfg = self.config.clone();
|
||||
let addr = lst.local_addr().unwrap();
|
||||
self.sockets.push(Socket {
|
||||
addr,
|
||||
scheme: "https",
|
||||
});
|
||||
|
||||
self.builder = Some(self.builder.take().unwrap().listen(
|
||||
format!("actix-web-service-{}", addr),
|
||||
lst,
|
||||
move || {
|
||||
let c = cfg.lock();
|
||||
acceptor.clone().map_err(|e| SslError::Ssl(e)).and_then(
|
||||
HttpService::build()
|
||||
.keep_alive(c.keep_alive)
|
||||
.client_timeout(c.client_timeout)
|
||||
.client_disconnect(c.client_shutdown)
|
||||
.finish(factory())
|
||||
.map_err(|e| SslError::Service(e))
|
||||
.map_init_err(|_| ()),
|
||||
)
|
||||
},
|
||||
)?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The socket address to bind
|
||||
|
@ -372,22 +398,6 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
// #[cfg(feature = "tls")]
|
||||
// /// The ssl socket address to bind
|
||||
// ///
|
||||
// /// To bind multiple addresses this method can be called multiple times.
|
||||
// pub fn bind_nativetls<A: net::ToSocketAddrs>(
|
||||
// self,
|
||||
// addr: A,
|
||||
// acceptor: TlsAcceptor,
|
||||
// ) -> io::Result<Self> {
|
||||
// use actix_server::ssl::NativeTlsAcceptor;
|
||||
|
||||
// self.bind_with(addr, move || {
|
||||
// NativeTlsAcceptor::new(acceptor.clone()).map_err(|_| ())
|
||||
// })
|
||||
// }
|
||||
|
||||
#[cfg(feature = "ssl")]
|
||||
/// Start listening for incoming tls connections.
|
||||
///
|
||||
|
@ -415,16 +425,15 @@ where
|
|||
///
|
||||
/// This method sets alpn protocols to "h2" and "http/1.1"
|
||||
pub fn bind_rustls<A: net::ToSocketAddrs>(
|
||||
self,
|
||||
mut self,
|
||||
addr: A,
|
||||
builder: ServerConfig,
|
||||
config: RustlsServerConfig,
|
||||
) -> io::Result<Self> {
|
||||
use super::{RustlsAcceptor, ServerFlags};
|
||||
use actix_service::NewServiceExt;
|
||||
|
||||
self.bind_with(addr, move || {
|
||||
RustlsAcceptor::with_flags(builder.clone(), flags).map_err(|_| ())
|
||||
})
|
||||
let sockets = self.bind2(addr)?;
|
||||
for lst in sockets {
|
||||
self.listen_rustls_inner(lst, config.clone())?;
|
||||
}
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,31 +1,20 @@
|
|||
-----BEGIN CERTIFICATE-----
|
||||
MIIFXTCCA0WgAwIBAgIJAJ3tqfd0MLLNMA0GCSqGSIb3DQEBCwUAMGExCzAJBgNV
|
||||
BAYTAlVTMQswCQYDVQQIDAJDRjELMAkGA1UEBwwCU0YxEDAOBgNVBAoMB0NvbXBh
|
||||
bnkxDDAKBgNVBAsMA09yZzEYMBYGA1UEAwwPd3d3LmV4YW1wbGUuY29tMB4XDTE4
|
||||
MDcyOTE4MDgzNFoXDTE5MDcyOTE4MDgzNFowYTELMAkGA1UEBhMCVVMxCzAJBgNV
|
||||
BAgMAkNGMQswCQYDVQQHDAJTRjEQMA4GA1UECgwHQ29tcGFueTEMMAoGA1UECwwD
|
||||
T3JnMRgwFgYDVQQDDA93d3cuZXhhbXBsZS5jb20wggIiMA0GCSqGSIb3DQEBAQUA
|
||||
A4ICDwAwggIKAoICAQDZbMgDYilVH1Nv0QWEhOXG6ETmtjZrdLqrNg3NBWBIWCDF
|
||||
cQ+fyTWxARx6vkF8A/3zpJyTcfQW8HgG38jw/A61QKaHBxzwq0HlNwY9Hh+Neeuk
|
||||
L4wgrlQ0uTC7IEMrOJjNN0GPyRQVfVbGa8QcSCpOg85l8GCxLvVwkBH/M5atoMtJ
|
||||
EzniNfK+gtk3hOL2tBqBCu9NDjhXPnJwNDLtTG1tQaHUJW/r281Wvv9I46H83DkU
|
||||
05lYtauh0bKh5znCH2KpFmBGqJNRzou3tXZFZzZfaCPBJPZR8j5TjoinehpDtkPh
|
||||
4CSio0PF2eIFkDKRUbdz/327HgEARJMXx+w1yHpS2JwHFgy5O76i68/Sm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tHx4cl1dJXS/iApOLLieU
|
||||
zyUGkwfsqjHPAZ7GacICeBojIn/7KdPdlSKAbGVAU3d4qzvFS0qmWzObplBz3niT
|
||||
Xnep2XLaVXqwlFJZZ6AHeKzYmMH0d0raiou2bpEUBqYizy2fi3NI4mA=
|
||||
-----END RSA PRIVATE KEY-----
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
use std::io::{Read, Write};
|
||||
use std::sync::mpsc;
|
||||
use std::thread;
|
||||
|
||||
use actix_http::http::header::{
|
||||
ContentEncoding, ACCEPT_ENCODING, CONTENT_ENCODING, CONTENT_LENGTH,
|
||||
|
@ -14,10 +16,12 @@ use flate2::Compression;
|
|||
use futures::stream::once;
|
||||
use rand::{distributions::Alphanumeric, Rng};
|
||||
|
||||
use actix_web::{dev::HttpMessageBody, web, App};
|
||||
use actix_web::{dev::HttpMessageBody, http, test, web, App, HttpResponse, HttpServer};
|
||||
|
||||
#[cfg(any(feature = "brotli", feature = "flate2-zlib", feature = "flate2-rust"))]
|
||||
use actix_web::middleware::encoding;
|
||||
#[cfg(any(feature = "brotli", feature = "flate2-zlib", feature = "flate2-rust"))]
|
||||
use actix_web::middleware::encoding::BodyEncoding;
|
||||
|
||||
const STR: &str = "Hello World Hello World Hello World Hello World Hello World \
|
||||
Hello World Hello World Hello World Hello World Hello World \
|
||||
|
@ -678,69 +682,93 @@ fn test_brotli_encoding_large() {
|
|||
// assert_eq!(bytes, Bytes::from(data));
|
||||
// }
|
||||
|
||||
// #[cfg(all(feature = "rust-tls", feature = "ssl"))]
|
||||
// #[test]
|
||||
// fn test_reading_deflate_encoding_large_random_ssl() {
|
||||
// use actix::{Actor, System};
|
||||
// use openssl::ssl::{SslConnector, SslMethod, SslVerifyMode};
|
||||
// use rustls::internal::pemfile::{certs, rsa_private_keys};
|
||||
// use rustls::{NoClientAuth, ServerConfig};
|
||||
// use std::fs::File;
|
||||
// use std::io::BufReader;
|
||||
#[cfg(all(
|
||||
feature = "rust-tls",
|
||||
feature = "ssl",
|
||||
any(feature = "flate2-zlib", feature = "flate2-rust")
|
||||
))]
|
||||
#[test]
|
||||
fn test_reading_deflate_encoding_large_random_ssl() {
|
||||
use openssl::ssl::{SslConnector, SslMethod, SslVerifyMode};
|
||||
use rustls::internal::pemfile::{certs, rsa_private_keys};
|
||||
use rustls::{NoClientAuth, ServerConfig};
|
||||
use std::fs::File;
|
||||
use std::io::BufReader;
|
||||
|
||||
// // load ssl keys
|
||||
// let mut config = ServerConfig::new(NoClientAuth::new());
|
||||
// let cert_file = &mut BufReader::new(File::open("tests/cert.pem").unwrap());
|
||||
// let key_file = &mut BufReader::new(File::open("tests/key.pem").unwrap());
|
||||
// let cert_chain = certs(cert_file).unwrap();
|
||||
// let mut keys = rsa_private_keys(key_file).unwrap();
|
||||
// config.set_single_cert(cert_chain, keys.remove(0)).unwrap();
|
||||
let addr = TestServer::unused_addr();
|
||||
let (tx, rx) = mpsc::channel();
|
||||
|
||||
// let data = rand::thread_rng()
|
||||
// .sample_iter(&Alphanumeric)
|
||||
// .take(160_000)
|
||||
// .collect::<String>();
|
||||
let data = rand::thread_rng()
|
||||
.sample_iter(&Alphanumeric)
|
||||
.take(160_000)
|
||||
.collect::<String>();
|
||||
|
||||
// let srv = test::TestServer::build().rustls(config).start(|app| {
|
||||
// app.handler(|req: &HttpRequest| {
|
||||
// req.body()
|
||||
// .and_then(|bytes: Bytes| {
|
||||
// Ok(HttpResponse::Ok()
|
||||
// .content_encoding(http::ContentEncoding::Identity)
|
||||
// .body(bytes))
|
||||
// })
|
||||
// .responder()
|
||||
// })
|
||||
// });
|
||||
thread::spawn(move || {
|
||||
let sys = actix_rt::System::new("test");
|
||||
|
||||
// let mut rt = System::new("test");
|
||||
// load ssl keys
|
||||
let mut config = ServerConfig::new(NoClientAuth::new());
|
||||
let cert_file = &mut BufReader::new(File::open("tests/cert.pem").unwrap());
|
||||
let key_file = &mut BufReader::new(File::open("tests/key.pem").unwrap());
|
||||
let cert_chain = certs(cert_file).unwrap();
|
||||
let mut keys = rsa_private_keys(key_file).unwrap();
|
||||
config.set_single_cert(cert_chain, keys.remove(0)).unwrap();
|
||||
|
||||
// // client connector
|
||||
// let mut builder = SslConnector::builder(SslMethod::tls()).unwrap();
|
||||
// builder.set_verify(SslVerifyMode::NONE);
|
||||
// let conn = client::ClientConnector::with_connector(builder.build()).start();
|
||||
let srv = HttpServer::new(|| {
|
||||
App::new().service(web::resource("/").route(web::to(|bytes: Bytes| {
|
||||
Ok::<_, Error>(
|
||||
HttpResponse::Ok()
|
||||
.encoding(http::ContentEncoding::Identity)
|
||||
.body(bytes),
|
||||
)
|
||||
})))
|
||||
})
|
||||
.bind_rustls(addr, config)
|
||||
.unwrap()
|
||||
.start();
|
||||
|
||||
// // encode data
|
||||
// let mut e = ZlibEncoder::new(Vec::new(), Compression::default());
|
||||
// e.write_all(data.as_ref()).unwrap();
|
||||
// let enc = e.finish().unwrap();
|
||||
let _ = tx.send((srv, actix_rt::System::current()));
|
||||
let _ = sys.run();
|
||||
});
|
||||
let (srv, _sys) = rx.recv().unwrap();
|
||||
let client = test::run_on(|| {
|
||||
let mut builder = SslConnector::builder(SslMethod::tls()).unwrap();
|
||||
builder.set_verify(SslVerifyMode::NONE);
|
||||
let _ = builder.set_alpn_protos(b"\x02h2\x08http/1.1").unwrap();
|
||||
|
||||
// // client request
|
||||
// let request = client::ClientRequest::build()
|
||||
// .uri(srv.url("/"))
|
||||
// .method(http::Method::POST)
|
||||
// .header(http::header::CONTENT_ENCODING, "deflate")
|
||||
// .with_connector(conn)
|
||||
// .body(enc)
|
||||
// .unwrap();
|
||||
// let response = rt.block_on(request.send()).unwrap();
|
||||
// assert!(response.status().is_success());
|
||||
awc::Client::build()
|
||||
.connector(
|
||||
awc::Connector::new()
|
||||
.timeout(std::time::Duration::from_millis(500))
|
||||
.ssl(builder.build())
|
||||
.service(),
|
||||
)
|
||||
.finish()
|
||||
});
|
||||
|
||||
// // read response
|
||||
// let bytes = rt.block_on(response.body()).unwrap();
|
||||
// assert_eq!(bytes.len(), data.len());
|
||||
// assert_eq!(bytes, Bytes::from(data));
|
||||
// }
|
||||
// encode data
|
||||
let mut e = ZlibEncoder::new(Vec::new(), Compression::default());
|
||||
e.write_all(data.as_ref()).unwrap();
|
||||
let enc = e.finish().unwrap();
|
||||
|
||||
// client request
|
||||
let _req = client
|
||||
.post(format!("https://{}/", addr))
|
||||
.header(http::header::CONTENT_ENCODING, "deflate")
|
||||
.send_body(enc);
|
||||
|
||||
// TODO: fix
|
||||
// let response = test::block_on(req).unwrap();
|
||||
// assert!(response.status().is_success());
|
||||
|
||||
// read response
|
||||
// let bytes = test::block_on(response.body()).unwrap();
|
||||
// assert_eq!(bytes.len(), data.len());
|
||||
// assert_eq!(bytes, Bytes::from(data));
|
||||
|
||||
// stop
|
||||
let _ = srv.stop(false);
|
||||
}
|
||||
|
||||
// #[cfg(all(feature = "tls", feature = "ssl"))]
|
||||
// #[test]
|
||||
|
|
Loading…
Reference in a new issue