Skip to content

Commit 612940f

Browse files
authored
Merge pull request #150 from Dstack-TEE/prpc-client-https
Support https for prpc client
2 parents 4126127 + 1bd98c2 commit 612940f

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

http-client/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ hyperlocal.workspace = true
1414
log.workspace = true
1515
pin-project-lite = "0.2.15"
1616
prpc = { workspace = true, optional = true }
17+
reqwest.workspace = true
1718
serde.workspace = true
1819
tokio.workspace = true
1920
tokio-vsock.workspace = true

http-client/src/lib.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use anyhow::Result;
22
use http_body_util::{BodyExt, Full};
33
use hyper::body::Bytes;
44
use hyper::Request;
5-
use hyper_util::client::legacy::{connect::HttpConnector, Client};
5+
use hyper_util::client::legacy::Client;
66
use hyper_vsock::VsockClientExt;
77
use hyperlocal::{UnixClientExt, UnixConnector, Uri};
88
use log::debug;
@@ -54,15 +54,13 @@ pub async fn http_request(
5454
.body(Full::new(Bytes::copy_from_slice(body)))?;
5555
client.request(req).await?
5656
} else {
57-
let client =
58-
Client::builder(hyper_util::rt::TokioExecutor::new()).build(HttpConnector::new());
59-
60-
let uri = mk_url(base, path).parse::<hyper::Uri>()?;
61-
let req = Request::builder()
62-
.method(method)
63-
.uri(uri)
64-
.body(Full::new(Bytes::copy_from_slice(body)))?;
65-
client.request(req).await?
57+
let uri = mk_url(base, path);
58+
let client = reqwest::Client::builder().build()?;
59+
let response = client.post(uri).body(body.to_vec()).send().await?;
60+
return Ok((
61+
response.status().as_u16(),
62+
response.text().await?.into_bytes(),
63+
));
6664
};
6765
debug!("Response: {:?}", response);
6866
let mut body = Vec::new();

0 commit comments

Comments
 (0)