mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-27 17:22:57 +01:00
Do not override current System
This commit is contained in:
parent
a32573bb58
commit
e4503046de
@ -1,10 +1,15 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## [0.2.5] - 2019-0917
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
* Update serde_urlencoded to "0.6.1"
|
* Update serde_urlencoded to "0.6.1"
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
* Do not override current `System`
|
||||||
|
|
||||||
|
|
||||||
## [0.2.4] - 2019-07-18
|
## [0.2.4] - 2019-07-18
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "actix-http-test"
|
name = "actix-http-test"
|
||||||
version = "0.2.4"
|
version = "0.2.5"
|
||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
description = "Actix http test server"
|
description = "Actix http test server"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
@ -35,7 +35,7 @@ actix-rt = "0.2.2"
|
|||||||
actix-service = "0.4.1"
|
actix-service = "0.4.1"
|
||||||
actix-server = "0.6.0"
|
actix-server = "0.6.0"
|
||||||
actix-utils = "0.4.1"
|
actix-utils = "0.4.1"
|
||||||
awc = "0.2.2"
|
awc = "0.2.6"
|
||||||
actix-connect = "0.2.2"
|
actix-connect = "0.2.2"
|
||||||
|
|
||||||
base64 = "0.10"
|
base64 = "0.10"
|
||||||
@ -56,5 +56,5 @@ tokio-timer = "0.2"
|
|||||||
openssl = { version="0.10", optional = true }
|
openssl = { version="0.10", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-web = "1.0.0"
|
actix-web = "1.0.7"
|
||||||
actix-http = "0.2.4"
|
actix-http = "0.2.9"
|
||||||
|
@ -103,8 +103,8 @@ pub struct TestServer;
|
|||||||
/// Test server controller
|
/// Test server controller
|
||||||
pub struct TestServerRuntime {
|
pub struct TestServerRuntime {
|
||||||
addr: net::SocketAddr,
|
addr: net::SocketAddr,
|
||||||
rt: Runtime,
|
|
||||||
client: Client,
|
client: Client,
|
||||||
|
system: System,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestServer {
|
impl TestServer {
|
||||||
@ -130,45 +130,47 @@ impl TestServer {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let (system, addr) = rx.recv().unwrap();
|
let (system, addr) = rx.recv().unwrap();
|
||||||
let mut rt = Runtime::new().unwrap();
|
|
||||||
|
|
||||||
let client = rt
|
let client = block_on(lazy(move || {
|
||||||
.block_on(lazy(move || {
|
let connector = {
|
||||||
let connector = {
|
#[cfg(feature = "ssl")]
|
||||||
#[cfg(feature = "ssl")]
|
{
|
||||||
{
|
use openssl::ssl::{SslConnector, SslMethod, SslVerifyMode};
|
||||||
use openssl::ssl::{SslConnector, SslMethod, SslVerifyMode};
|
|
||||||
|
|
||||||
let mut builder =
|
let mut builder = SslConnector::builder(SslMethod::tls()).unwrap();
|
||||||
SslConnector::builder(SslMethod::tls()).unwrap();
|
builder.set_verify(SslVerifyMode::NONE);
|
||||||
builder.set_verify(SslVerifyMode::NONE);
|
let _ = builder
|
||||||
let _ = builder.set_alpn_protos(b"\x02h2\x08http/1.1").map_err(
|
.set_alpn_protos(b"\x02h2\x08http/1.1")
|
||||||
|e| log::error!("Can not set alpn protocol: {:?}", e),
|
.map_err(|e| log::error!("Can not set alpn protocol: {:?}", e));
|
||||||
);
|
Connector::new()
|
||||||
Connector::new()
|
.conn_lifetime(time::Duration::from_secs(0))
|
||||||
.conn_lifetime(time::Duration::from_secs(0))
|
.timeout(time::Duration::from_millis(500))
|
||||||
.timeout(time::Duration::from_millis(500))
|
.ssl(builder.build())
|
||||||
.ssl(builder.build())
|
.finish()
|
||||||
.finish()
|
}
|
||||||
}
|
#[cfg(not(feature = "ssl"))]
|
||||||
#[cfg(not(feature = "ssl"))]
|
{
|
||||||
{
|
Connector::new()
|
||||||
Connector::new()
|
.conn_lifetime(time::Duration::from_secs(0))
|
||||||
.conn_lifetime(time::Duration::from_secs(0))
|
.timeout(time::Duration::from_millis(500))
|
||||||
.timeout(time::Duration::from_millis(500))
|
.finish()
|
||||||
.finish()
|
}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
|
|
||||||
Ok::<Client, ()>(Client::build().connector(connector).finish())
|
Ok::<Client, ()>(Client::build().connector(connector).finish())
|
||||||
}))
|
}))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
rt.block_on(lazy(
|
|
||||||
|
block_on(lazy(
|
||||||
|| Ok::<_, ()>(actix_connect::start_default_resolver()),
|
|| Ok::<_, ()>(actix_connect::start_default_resolver()),
|
||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
System::set_current(system);
|
|
||||||
TestServerRuntime { addr, rt, client }
|
TestServerRuntime {
|
||||||
|
addr,
|
||||||
|
client,
|
||||||
|
system,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get first available unused address
|
/// Get first available unused address
|
||||||
@ -188,7 +190,7 @@ impl TestServerRuntime {
|
|||||||
where
|
where
|
||||||
F: Future<Item = I, Error = E>,
|
F: Future<Item = I, Error = E>,
|
||||||
{
|
{
|
||||||
self.rt.block_on(fut)
|
block_on(fut)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Execute future on current core
|
/// Execute future on current core
|
||||||
@ -197,7 +199,7 @@ impl TestServerRuntime {
|
|||||||
F: FnOnce() -> R,
|
F: FnOnce() -> R,
|
||||||
R: Future,
|
R: Future,
|
||||||
{
|
{
|
||||||
self.rt.block_on(lazy(f))
|
block_on(lazy(f))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Execute function on current core
|
/// Execute function on current core
|
||||||
@ -205,7 +207,7 @@ impl TestServerRuntime {
|
|||||||
where
|
where
|
||||||
F: FnOnce() -> R,
|
F: FnOnce() -> R,
|
||||||
{
|
{
|
||||||
self.rt.block_on(lazy(|| Ok::<_, ()>(fut()))).unwrap()
|
block_on(lazy(|| Ok::<_, ()>(fut()))).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct test server url
|
/// Construct test server url
|
||||||
@ -324,8 +326,7 @@ impl TestServerRuntime {
|
|||||||
{
|
{
|
||||||
let url = self.url(path);
|
let url = self.url(path);
|
||||||
let connect = self.client.ws(url).connect();
|
let connect = self.client.ws(url).connect();
|
||||||
self.rt
|
block_on(lazy(move || connect.map(|(_, framed)| framed)))
|
||||||
.block_on(lazy(move || connect.map(|(_, framed)| framed)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Connect to a websocket server
|
/// Connect to a websocket server
|
||||||
@ -338,7 +339,7 @@ impl TestServerRuntime {
|
|||||||
|
|
||||||
/// Stop http server
|
/// Stop http server
|
||||||
fn stop(&mut self) {
|
fn stop(&mut self) {
|
||||||
System::current().stop();
|
self.system.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user