mirror of
https://github.com/fafhrd91/actix-web
synced 2025-01-18 22:01:50 +01:00
test-server: Replace net2
crate with socket2
This commit is contained in:
parent
74491dca59
commit
2dac9afc4e
@ -6,6 +6,7 @@
|
|||||||
* Update `actix-connect` dependency to 2.0.0-alpha.2
|
* Update `actix-connect` dependency to 2.0.0-alpha.2
|
||||||
* Make `test_server` `async` fn.
|
* Make `test_server` `async` fn.
|
||||||
* Bump minimum supported Rust version to 1.40
|
* Bump minimum supported Rust version to 1.40
|
||||||
|
* Replace deprecated `net2` crate with `socket2`
|
||||||
|
|
||||||
## [1.0.0] - 2019-12-13
|
## [1.0.0] - 2019-12-13
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ futures-core = { version = "0.3.5", default-features = false }
|
|||||||
http = "0.2.0"
|
http = "0.2.0"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
env_logger = "0.6"
|
env_logger = "0.6"
|
||||||
net2 = "0.2"
|
socket2 = "0.3"
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
sha1 = "0.6"
|
sha1 = "0.6"
|
||||||
|
@ -9,7 +9,7 @@ use awc::{error::PayloadError, ws, Client, ClientRequest, ClientResponse, Connec
|
|||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures_core::stream::Stream;
|
use futures_core::stream::Stream;
|
||||||
use http::Method;
|
use http::Method;
|
||||||
use net2::TcpBuilder;
|
use socket2::{Domain, Protocol, Socket, Type};
|
||||||
|
|
||||||
pub use actix_testing::*;
|
pub use actix_testing::*;
|
||||||
|
|
||||||
@ -104,10 +104,10 @@ pub async fn test_server<F: ServiceFactory<TcpStream>>(factory: F) -> TestServer
|
|||||||
/// Get first available unused address
|
/// Get first available unused address
|
||||||
pub fn unused_addr() -> net::SocketAddr {
|
pub fn unused_addr() -> net::SocketAddr {
|
||||||
let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
|
let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
|
||||||
let socket = TcpBuilder::new_v4().unwrap();
|
let socket = Socket::new(Domain::ipv4(), Type::stream(), Some(Protocol::tcp())).unwrap();
|
||||||
socket.bind(&addr).unwrap();
|
socket.bind(&addr.into()).unwrap();
|
||||||
socket.reuse_address(true).unwrap();
|
socket.set_reuse_address(true).unwrap();
|
||||||
let tcp = socket.to_tcp_listener().unwrap();
|
let tcp = socket.into_tcp_listener();
|
||||||
tcp.local_addr().unwrap()
|
tcp.local_addr().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user