1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-30 00:14:58 +02:00

web: Replace net2 crate with socket2

This commit is contained in:
Yuki Okushi
2020-05-19 09:34:37 +09:00
parent 2dac9afc4e
commit 9a7f93610a
5 changed files with 21 additions and 28 deletions

View File

@ -1,25 +1,15 @@
use net2::TcpBuilder;
use std::sync::mpsc;
use std::{net, thread, time::Duration};
use std::{thread, time::Duration};
#[cfg(feature = "openssl")]
use open_ssl::ssl::SslAcceptorBuilder;
use actix_web::{web, App, HttpResponse, HttpServer};
fn unused_addr() -> net::SocketAddr {
let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
let socket = TcpBuilder::new_v4().unwrap();
socket.bind(&addr).unwrap();
socket.reuse_address(true).unwrap();
let tcp = socket.to_tcp_listener().unwrap();
tcp.local_addr().unwrap()
}
use actix_web::{test, web, App, HttpResponse, HttpServer};
#[cfg(unix)]
#[actix_rt::test]
async fn test_start() {
let addr = unused_addr();
let addr = test::unused_addr();
let (tx, rx) = mpsc::channel();
thread::spawn(move || {
@ -92,7 +82,7 @@ fn ssl_acceptor() -> std::io::Result<SslAcceptorBuilder> {
async fn test_start_ssl() {
use actix_web::HttpRequest;
let addr = unused_addr();
let addr = test::unused_addr();
let (tx, rx) = mpsc::channel();
thread::spawn(move || {