mirror of
https://github.com/actix/examples
synced 2024-11-23 22:41:07 +01:00
Updated security/awc_https to v4. (#517)
This commit is contained in:
parent
c960da6bdb
commit
3cd842fbd5
@ -2,8 +2,9 @@
|
||||
name = "awc_https"
|
||||
version = "0.1.0"
|
||||
authors = ["dowwie <dkcdkg@gmail.com>"]
|
||||
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"
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user