mirror of
https://github.com/actix/examples
synced 2024-11-27 16:02:57 +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"
|
name = "awc_https"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["dowwie <dkcdkg@gmail.com>"]
|
authors = ["dowwie <dkcdkg@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = { version = "3", features = ["openssl"] }
|
actix-web = "4.0.0-beta.21"
|
||||||
openssl = "0.10.28"
|
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
|
careful about setting up https communication. **You could use the default
|
||||||
awc api without configuring ssl but performance will be severely diminished**.
|
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:
|
To run:
|
||||||
> curl http://localhost:3000 -o image.jpg
|
> curl http://localhost:3000 -o image.jpg
|
||||||
|
@ -1,20 +1,18 @@
|
|||||||
use actix_web::{
|
use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer};
|
||||||
client::{Client, Connector},
|
use awc::{Client, Connector};
|
||||||
web, App, HttpRequest, HttpResponse, HttpServer,
|
|
||||||
};
|
|
||||||
use openssl::ssl::{SslConnector, SslMethod};
|
use openssl::ssl::{SslConnector, SslMethod};
|
||||||
|
|
||||||
async fn index(_req: HttpRequest) -> HttpResponse {
|
async fn index(_req: HttpRequest) -> HttpResponse {
|
||||||
let builder = SslConnector::builder(SslMethod::tls()).unwrap();
|
let builder = SslConnector::builder(SslMethod::tls()).unwrap();
|
||||||
|
|
||||||
let client = Client::builder()
|
let client = Client::builder()
|
||||||
.connector(Connector::new().ssl(builder.build()).finish())
|
.connector(Connector::new().openssl(builder.build()))
|
||||||
.finish();
|
.finish();
|
||||||
|
|
||||||
let now = std::time::Instant::now();
|
let now = std::time::Instant::now();
|
||||||
let payload =
|
let payload =
|
||||||
client
|
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()
|
.send()
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
Loading…
Reference in New Issue
Block a user