From 3cd842fbd54830c012b36ea2fabd10ab6ac8e9a3 Mon Sep 17 00:00:00 2001 From: Christopher Gubbin <44929740+cgubbin@users.noreply.github.com> Date: Wed, 2 Feb 2022 00:45:49 +0000 Subject: [PATCH] Updated security/awc_https to v4. (#517) --- security/awc_https/Cargo.toml | 7 ++++--- security/awc_https/README.md | 2 +- security/awc_https/src/main.rs | 10 ++++------ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/security/awc_https/Cargo.toml b/security/awc_https/Cargo.toml index fb38828..dbe26b2 100644 --- a/security/awc_https/Cargo.toml +++ b/security/awc_https/Cargo.toml @@ -2,8 +2,9 @@ name = "awc_https" version = "0.1.0" authors = ["dowwie "] -edition = "2018" +edition = "2021" [dependencies] -actix-web = { version = "3", features = ["openssl"] } -openssl = "0.10.28" +actix-web = "4.0.0-beta.21" +awc = {version = "3.0.0-beta.19", features = ["openssl"]} +openssl = "0.10.38" diff --git a/security/awc_https/README.md b/security/awc_https/README.md index fd768e6..ba0c36e 100644 --- a/security/awc_https/README.md +++ b/security/awc_https/README.md @@ -3,7 +3,7 @@ for https related communication. As of actix-web 2.0.0, one must be very careful about setting up https communication. **You could use the default awc api without configuring ssl but performance will be severely diminished**. -This example downloads a 10MB image from wikipedia. +This example downloads a 1MB image from wikipedia. To run: > curl http://localhost:3000 -o image.jpg diff --git a/security/awc_https/src/main.rs b/security/awc_https/src/main.rs index c4da375..375b848 100644 --- a/security/awc_https/src/main.rs +++ b/security/awc_https/src/main.rs @@ -1,20 +1,18 @@ -use actix_web::{ - client::{Client, Connector}, - web, App, HttpRequest, HttpResponse, HttpServer, -}; +use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer}; +use awc::{Client, Connector}; use openssl::ssl::{SslConnector, SslMethod}; async fn index(_req: HttpRequest) -> HttpResponse { let builder = SslConnector::builder(SslMethod::tls()).unwrap(); let client = Client::builder() - .connector(Connector::new().ssl(builder.build()).finish()) + .connector(Connector::new().openssl(builder.build())) .finish(); let now = std::time::Instant::now(); let payload = client - .get("https://upload.wikimedia.org/wikipedia/commons/f/ff/Pizigani_1367_Chart_10MB.jpg") + .get("https://upload.wikimedia.org/wikipedia/commons/b/b9/Pizigani_1367_Chart_1MB.jpg") .send() .await .unwrap()