Skip to content

Commit b58f2da

Browse files
KixironJoshua Nelson
authored and
Joshua Nelson
committed
Updated Reqwest
1 parent a9794cd commit b58f2da

File tree

6 files changed

+22
-146
lines changed

6 files changed

+22
-146
lines changed

Cargo.lock

Lines changed: 1 addition & 133 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
@@ -13,7 +13,7 @@ log = "0.4"
1313
regex = "1"
1414
structopt = "0.3"
1515
crates-index-diff = "7"
16-
reqwest = "0.9"
16+
reqwest = { version = "0.10.6", features = ["blocking"] } # TODO: Remove blocking when async is ready
1717
semver = "0.9"
1818
slug = "=0.1.1"
1919
env_logger = "0.7"

src/index/api.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,19 @@ impl RegistryCrateData {
4040
}
4141
}
4242

43-
fn client() -> Result<reqwest::Client> {
43+
fn client() -> Result<reqwest::blocking::Client> {
4444
let headers = vec![
4545
(USER_AGENT, HeaderValue::from_static(APP_USER_AGENT)),
4646
(ACCEPT, HeaderValue::from_static("application/json")),
4747
]
4848
.into_iter()
4949
.collect();
5050

51-
Ok(reqwest::Client::builder()
51+
let client = reqwest::blocking::Client::builder()
5252
.default_headers(headers)
53-
.build()?)
53+
.build()?;
54+
55+
Ok(client)
5456
}
5557

5658
/// Get release_time, yanked and downloads from the registry's API

src/test/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ use failure::Error;
66
use log::error;
77
use once_cell::unsync::OnceCell;
88
use postgres::Connection;
9-
use reqwest::{Client, Method, RequestBuilder};
10-
use std::panic;
11-
use std::sync::{Arc, Mutex, MutexGuard};
9+
use reqwest::{
10+
blocking::{Client, RequestBuilder},
11+
Method,
12+
};
13+
use std::{
14+
panic,
15+
sync::{Arc, Mutex, MutexGuard},
16+
};
1217

1318
pub(crate) fn wrapper(f: impl FnOnce(&TestEnvironment) -> Result<(), Error>) {
1419
let _ = dotenv::dotenv();

src/utils/github_updater.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,8 @@ fn get_github_fields(path: &str) -> Result<GitHubFields> {
7777
use serde_json::Value;
7878

7979
let body = {
80-
use reqwest::header::USER_AGENT;
81-
use reqwest::{Client, StatusCode};
82-
use std::env;
83-
use std::io::Read;
80+
use reqwest::{blocking::Client, header::USER_AGENT, StatusCode};
81+
use std::{env, io::Read};
8482

8583
let client = Client::new();
8684
let mut body = String::new();

src/utils/pubsubhubbub.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
use reqwest::{
2+
blocking::{Client, Response},
3+
Result,
4+
};
15
use std::collections::HashMap;
26

3-
use reqwest::*;
4-
57
fn ping_hub(url: &str) -> Result<Response> {
68
let mut params = HashMap::with_capacity(2);
79
params.insert("hub.mode", "publish");
810
params.insert("hub.url", "https://docs.rs/releases/feed");
11+
912
let client = Client::new();
1013
client.post(url).form(&params).send()
1114
}

0 commit comments

Comments
 (0)