Actix-web : implement HTTPS proxy

HTTPS proxy works in a different way than HTTP proxy.

First client sends CONNECT

Proxy-Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36


After proxy server establishes a TCP connection to target and response 200 to client, a tunnel is opened and this TCP connection is proxied with raw data.

My question is: How can I access the raw socket after sending HTTP response 200 to client?

HttpServer::new(|| {
.bind_rustls(format!("{}", port), config)
.expect(&format!("Unable to bind on rustls port {}", port))

fn handle_connect(req: HttpRequest, stream: web::Payload) -> impl futures01::future::Future<Item=HttpResponse, Error=()> {
    async_handle_connect_request(req, stream).unit_error().boxed_local().compat()

async fn async_handle_connect_request(_req: HttpRequest, _stream: web::Payload) -> HttpResponse {
    return HttpResponse::Ok().finish();