|
2 | 2 | // License, v. 2.0. If a copy of the MPL was not distributed with this
|
3 | 3 | // file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
4 | 4 |
|
5 |
| -use bytes::Bytes; |
6 |
| -use std::str::FromStr; |
7 |
| -use tokio::net::TcpStream; |
8 | 5 | use {
|
9 | 6 | crate::release::{produce_install_only, RELEASE_TRIPLES},
|
10 | 7 | anyhow::{anyhow, Result},
|
| 8 | + bytes::Bytes, |
11 | 9 | clap::ArgMatches,
|
12 | 10 | futures::StreamExt,
|
13 |
| - http::Method, |
14 | 11 | octocrab::{
|
15 | 12 | models::{repos::Release, workflows::WorkflowListArtifact},
|
16 | 13 | params::actions::ArchiveFormat,
|
@@ -69,31 +66,19 @@ async fn upload_release_artifact(
|
69 | 66 | // Octocrab doesn't yet support release artifact upload. And the low-level HTTP API
|
70 | 67 | // forces the use of strings on us. So we have to make our own HTTP client.
|
71 | 68 |
|
72 |
| - let uri = hyper::Uri::from_str(url.as_str())?; |
73 |
| - |
74 |
| - let request = http::request::Builder::new() |
75 |
| - .method(Method::PUT) |
76 |
| - .uri(uri) |
77 |
| - .header("Authorization", format!("Bearer {auth_token}")) |
78 |
| - .header("Content-Length", data.len()) |
79 |
| - .header("Content-Type", "application/x-tar") |
80 |
| - .body(http_body_util::Full::new(data))?; |
81 |
| - |
82 | 69 | if dry_run {
|
83 | 70 | return Ok(());
|
84 | 71 | }
|
85 | 72 |
|
86 |
| - let host = url.host().ok_or_else(|| anyhow!("no host in URL"))?; |
87 |
| - let port = url.port().unwrap_or(443); |
88 |
| - let address = format!("{host}:{port}"); |
89 |
| - |
90 |
| - let stream = TcpStream::connect(address).await?; |
91 |
| - let io = hyper_util::rt::TokioIo::new(stream); |
92 |
| - let (mut sender, conn) = hyper::client::conn::http1::handshake(io).await?; |
93 |
| - |
94 |
| - conn.await?; |
95 |
| - |
96 |
| - let response = sender.send_request(request).await?; |
| 73 | + let response = reqwest::Client::builder() |
| 74 | + .build()? |
| 75 | + .put(url) |
| 76 | + .header("Authorization", format!("Bearer {auth_token}")) |
| 77 | + .header("Content-Length", data.len()) |
| 78 | + .header("Content-Type", "application/x-tar") |
| 79 | + .body(data) |
| 80 | + .send() |
| 81 | + .await?; |
97 | 82 |
|
98 | 83 | if !response.status().is_success() {
|
99 | 84 | return Err(anyhow!("HTTP {}", response.status()));
|
|
0 commit comments