Skip to content

Commit eba3e49

Browse files
committed
Bump to prerelease reqwest
1 parent 16f84e9 commit eba3e49

File tree

14 files changed

+261
-389
lines changed

14 files changed

+261
-389
lines changed

Cargo.lock

Lines changed: 234 additions & 364 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 = "3.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.3", 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

@@ -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
@@ -47,7 +48,7 @@ impl Environment {
4748
index: Repository,
4849
connection_pool: DieselPool,
4950
uploader: Uploader,
50-
http_client: reqwest::Client,
51+
http_client: Client,
5152
) -> Self {
5253
Self {
5354
index: Arc::new(Mutex::new(index)),
@@ -68,7 +69,7 @@ impl Environment {
6869
}
6970

7071
/// Returns a client for making HTTP requests to upload crate files.
71-
pub(crate) fn http_client(&self) -> &reqwest::Client {
72+
pub(crate) fn http_client(&self) -> &Client {
7273
&self.http_client
7374
}
7475
}

src/bin/background-worker.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use cargo_registry::git::{Repository, RepositoryConfig};
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

@@ -43,12 +44,7 @@ fn main() {
4344
let repository = Repository::open(&repository_config).expect("Failed to clone index");
4445
println!("Index cloned");
4546

46-
let environment = Environment::new(
47-
repository,
48-
db_pool.clone(),
49-
config.uploader,
50-
reqwest::Client::new(),
51-
);
47+
let environment = Environment::new(repository, db_pool.clone(), config.uploader, Client::new());
5248

5349
let build_runner = || {
5450
swirl::Runner::builder(db_pool.clone(), environment.clone())

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::Error;
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::{header, Client};
24+
use reqwest::{blocking::Client, header};
2525
use tar::{self, Archive};
2626

2727
const CACHE_CONTROL_README: &str = "public,max-age=604800";
@@ -170,7 +170,7 @@ fn get_readme(
170170
.uploader
171171
.crate_location(krate_name, &version.num.to_string());
172172

173-
let mut response = match client.get(&location).send() {
173+
let response = match client.get(&location).send() {
174174
Ok(r) => r,
175175
Err(err) => {
176176
println!(

src/bin/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::{
1111
use civet::Server as CivetServer;
1212
use conduit_hyper::Service;
1313
use futures::prelude::*;
14-
use reqwest::Client;
14+
use reqwest::blocking::Client;
1515

1616
enum Server {
1717
Civet(CivetServer),

src/s3/Cargo.toml

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

src/s3/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ use openssl::error::ErrorStack;
66
use openssl::hash::MessageDigest;
77
use openssl::pkey::PKey;
88
use openssl::sign::Signer;
9-
use reqwest::{header, Body, Client, Response};
9+
use reqwest::{
10+
blocking::{Body, Client, Response},
11+
header,
12+
};
1013

1114
mod error;
1215
pub use error::Error;

src/tasks/dump_db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl DumpTarball {
152152
}
153153

154154
fn upload(&self, target_name: &str, uploader: &Uploader) -> Result<u64, PerformError> {
155-
let client = reqwest::Client::new();
155+
let client = reqwest::blocking::Client::new();
156156
let tarfile = File::open(&self.tarball_path)?;
157157
let content_length = tarfile.metadata()?.len();
158158
// 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
@@ -29,7 +29,7 @@ use std::{
2929

3030
use conduit_test::MockRequest;
3131
use diesel::prelude::*;
32-
use reqwest::{Client, Proxy};
32+
use reqwest::{blocking::Client, Proxy};
3333

3434
macro_rules! t {
3535
($e:expr) => {

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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use conduit::Request;
22
use flate2::read::GzDecoder;
33
use openssl::error::ErrorStack;
44
use openssl::hash::{Hasher, MessageDigest};
5-
use reqwest::header;
5+
use reqwest::{blocking::Client, header};
66

77
use crate::util::errors::{cargo_err, internal, AppResult, ChainError};
88
use crate::util::{Error, LimitErrorReader, Maximums};
@@ -96,7 +96,7 @@ impl Uploader {
9696
/// Production and tests use `Self::S3` which should not panic.
9797
pub fn upload<R: std::io::Read + Send + 'static>(
9898
&self,
99-
client: &reqwest::Client,
99+
client: &Client,
100100
path: &str,
101101
mut content: R,
102102
content_length: u64,
@@ -161,7 +161,7 @@ impl Uploader {
161161

162162
pub(crate) fn upload_readme(
163163
&self,
164-
http_client: &reqwest::Client,
164+
http_client: &Client,
165165
crate_name: &str,
166166
vers: &str,
167167
readme: String,

0 commit comments

Comments
 (0)