Skip to content

Commit 40f83b3

Browse files
committed
Bump to prerelease reqwest
1 parent 725d314 commit 40f83b3

File tree

14 files changed

+265
-345
lines changed

14 files changed

+265
-345
lines changed

Cargo.lock

Lines changed: 234 additions & 318 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ ammonia = "2.0.0"
5757
docopt = "1.0"
5858
scheduled-thread-pool = "0.2.0"
5959
derive_deref = "1.0.0"
60-
reqwest = "0.9.1"
60+
reqwest = { git = "https://github.com/seanmonstar/reqwest", features = ["blocking", "gzip", "json"] }
6161
tempdir = "0.3.7"
6262
parking_lot = "0.7.1"
6363
jemallocator = { version = "0.1.8", features = ['unprefixed_malloc_on_supported_platforms', 'profiling'] }

src/app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{path::PathBuf, sync::Arc, time::Duration};
55

66
use diesel::r2d2;
77
use oauth2::basic::BasicClient;
8-
use reqwest::Client;
8+
use reqwest::blocking::Client;
99
use scheduled_thread_pool::ScheduledThreadPool;
1010

1111
/// The `App` struct holds the main components of the application like

src/background_jobs.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use reqwest::blocking::Client;
12
use std::panic::AssertUnwindSafe;
23
use std::sync::{Arc, Mutex, MutexGuard, PoisonError};
34
use swirl::PerformError;
@@ -26,7 +27,7 @@ pub struct Environment {
2627
// FIXME: https://github.com/sfackler/r2d2/pull/70
2728
pub connection_pool: AssertUnwindSafe<DieselPool>,
2829
pub uploader: Uploader,
29-
http_client: AssertUnwindSafe<reqwest::Client>,
30+
http_client: AssertUnwindSafe<Client>,
3031
}
3132

3233
// FIXME: AssertUnwindSafe should be `Clone`, this can be replaced with
@@ -49,7 +50,7 @@ impl Environment {
4950
credentials: Option<(String, String)>,
5051
connection_pool: DieselPool,
5152
uploader: Uploader,
52-
http_client: reqwest::Client,
53+
http_client: Client,
5354
) -> Self {
5455
Self {
5556
index: Arc::new(Mutex::new(index)),
@@ -79,7 +80,7 @@ impl Environment {
7980
}
8081

8182
/// Returns a client for making HTTP requests to upload crate files.
82-
pub(crate) fn http_client(&self) -> &reqwest::Client {
83+
pub(crate) fn http_client(&self) -> &Client {
8384
&self.http_client
8485
}
8586
}

src/bin/background-worker.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use cargo_registry::git::Repository;
1616
use cargo_registry::{background_jobs::*, db};
1717
use diesel::r2d2;
18+
use reqwest::blocking::Client;
1819
use std::thread::sleep;
1920
use std::time::Duration;
2021

@@ -53,7 +54,7 @@ fn main() {
5354
credentials,
5455
db_pool.clone(),
5556
config.uploader,
56-
reqwest::Client::new(),
57+
Client::new(),
5758
);
5859

5960
let build_runner = || {

src/bin/on_call/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use cargo_registry::util::{internal, CargoResult};
22

3-
use reqwest::{header, StatusCode as Status};
3+
use reqwest::{blocking::Client, header, StatusCode as Status};
44

55
#[derive(serde::Serialize, Debug)]
66
#[serde(rename_all = "snake_case", tag = "event_type")]
@@ -29,7 +29,7 @@ impl Event {
2929
let api_token = dotenv::var("PAGERDUTY_API_TOKEN")?;
3030
let service_key = dotenv::var("PAGERDUTY_INTEGRATION_KEY")?;
3131

32-
let mut response = reqwest::Client::new()
32+
let response = Client::new()
3333
.post("https://events.pagerduty.com/generic/2010-04-15/create_event.json")
3434
.header(header::ACCEPT, "application/vnd.pagerduty+json;version=2")
3535
.header(header::AUTHORIZATION, format!("Token token={}", api_token))

src/bin/render-readmes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use chrono::{TimeZone, Utc};
2121
use diesel::{dsl::any, prelude::*};
2222
use docopt::Docopt;
2323
use flate2::read::GzDecoder;
24-
use reqwest::Client;
24+
use reqwest::blocking::Client;
2525
use tar::{self, Archive};
2626

2727
const DEFAULT_PAGE_SIZE: usize = 25;
@@ -162,7 +162,7 @@ fn get_readme(
162162
.uploader
163163
.crate_location(krate_name, &version.num.to_string());
164164

165-
let mut response = match client.get(&location).send() {
165+
let response = match client.get(&location).send() {
166166
Ok(r) => r,
167167
Err(err) => {
168168
println!(

src/bin/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use civet::Server as CivetServer;
1212
use conduit_hyper::Service;
1313
use futures::prelude::*;
1414
use jemalloc_ctl;
15-
use reqwest::Client;
15+
use reqwest::blocking::Client;
1616

1717
enum Server {
1818
Civet(CivetServer),

src/s3/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ path = "lib.rs"
1616
base64 = "0.6"
1717
chrono = "0.4"
1818
openssl = "0.10.13"
19-
reqwest = "0.9.1"
19+
reqwest = { git = "https://github.com/seanmonstar/reqwest", features = ["blocking"] }

src/s3/lib.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ use chrono::prelude::Utc;
1010
use openssl::hash::MessageDigest;
1111
use openssl::pkey::PKey;
1212
use openssl::sign::Signer;
13-
use reqwest::header;
13+
use reqwest::{
14+
blocking::{Body, Client, Response},
15+
header,
16+
};
1417

1518
#[derive(Clone, Debug)]
1619
pub struct Bucket {
@@ -40,12 +43,12 @@ impl Bucket {
4043

4144
pub fn put<R: std::io::Read + Send + 'static>(
4245
&self,
43-
client: &reqwest::Client,
46+
client: &Client,
4447
path: &str,
4548
content: R,
4649
content_length: u64,
4750
content_type: &str,
48-
) -> reqwest::Result<reqwest::Response> {
51+
) -> reqwest::Result<Response> {
4952
let path = if path.starts_with('/') {
5053
&path[1..]
5154
} else {
@@ -60,16 +63,12 @@ impl Bucket {
6063
.header(header::AUTHORIZATION, auth)
6164
.header(header::CONTENT_TYPE, content_type)
6265
.header(header::DATE, date)
63-
.body(reqwest::Body::sized(content, content_length))
66+
.body(Body::sized(content, content_length))
6467
.send()?
6568
.error_for_status()
6669
}
6770

68-
pub fn delete(
69-
&self,
70-
client: &reqwest::Client,
71-
path: &str,
72-
) -> reqwest::Result<reqwest::Response> {
71+
pub fn delete(&self, client: &Client, path: &str) -> reqwest::Result<Response> {
7372
let path = if path.starts_with('/') {
7473
&path[1..]
7574
} else {

src/tasks/dump_db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl DumpTarball {
146146
}
147147

148148
fn upload(&self, target_name: &str, uploader: &Uploader) -> Result<(), PerformError> {
149-
let client = reqwest::Client::new();
149+
let client = reqwest::blocking::Client::new();
150150
let tarfile = File::open(&self.tarball_path)?;
151151
let content_length = tarfile.metadata()?.len();
152152
// TODO Figure out the correct content type.

src/tests/all.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use std::{
3636

3737
use conduit_test::MockRequest;
3838
use diesel::prelude::*;
39-
use reqwest::{Client, Proxy};
39+
use reqwest::{blocking::Client, Proxy};
4040
use url::Url;
4141

4242
macro_rules! t {

src/tests/record.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ impl GhUser {
366366
client_id: String,
367367
client_secret: String,
368368
}
369-
let client = reqwest::Client::new();
369+
let client = reqwest::blocking::Client::new();
370370
let req = client
371371
.post("https://api.github.com/authorizations")
372372
.json(&Authorization {
@@ -377,7 +377,9 @@ impl GhUser {
377377
})
378378
.basic_auth(self.login, Some(password));
379379

380-
let mut response = t!(req.send().and_then(reqwest::Response::error_for_status));
380+
let response = t!(req
381+
.send()
382+
.and_then(reqwest::blocking::Response::error_for_status));
381383

382384
#[derive(Deserialize)]
383385
struct Response {

src/uploaders.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use conduit::Request;
22
use flate2::read::GzDecoder;
33
use openssl::hash::{Hasher, MessageDigest};
4+
use reqwest::blocking::Client;
45

56
use crate::util::LimitErrorReader;
67
use crate::util::{human, internal, CargoResult, ChainError, Maximums};
@@ -86,7 +87,7 @@ impl Uploader {
8687
/// It returns the path of the uploaded file.
8788
pub fn upload<R: std::io::Read + Send + 'static>(
8889
&self,
89-
client: &reqwest::Client,
90+
client: &Client,
9091
path: &str,
9192
mut content: R,
9293
content_length: u64,
@@ -138,7 +139,7 @@ impl Uploader {
138139

139140
pub(crate) fn upload_readme(
140141
&self,
141-
http_client: &reqwest::Client,
142+
http_client: &Client,
142143
crate_name: &str,
143144
vers: &str,
144145
readme: String,

0 commit comments

Comments
 (0)