Skip to content

Updated Reqwest #828

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 1 addition & 133 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ log = "0.4"
regex = "1"
structopt = "0.3"
crates-index-diff = "7"
reqwest = "0.9"
reqwest = { version = "0.10.6", features = ["blocking"] } # TODO: Remove blocking when async is ready
semver = "0.9"
slug = "=0.1.1"
env_logger = "0.7"
8 changes: 5 additions & 3 deletions src/index/api.rs
Original file line number Diff line number Diff line change
@@ -40,17 +40,19 @@ impl RegistryCrateData {
}
}

fn client() -> Result<reqwest::Client> {
fn client() -> Result<reqwest::blocking::Client> {
let headers = vec![
(USER_AGENT, HeaderValue::from_static(APP_USER_AGENT)),
(ACCEPT, HeaderValue::from_static("application/json")),
]
.into_iter()
.collect();

Ok(reqwest::Client::builder()
let client = reqwest::blocking::Client::builder()
.default_headers(headers)
.build()?)
.build()?;

Ok(client)
}

/// Get release_time, yanked and downloads from the registry's API
11 changes: 8 additions & 3 deletions src/test/mod.rs
Original file line number Diff line number Diff line change
@@ -6,9 +6,14 @@ use failure::Error;
use log::error;
use once_cell::unsync::OnceCell;
use postgres::Connection;
use reqwest::{Client, Method, RequestBuilder};
use std::panic;
use std::sync::{Arc, Mutex, MutexGuard};
use reqwest::{
blocking::{Client, RequestBuilder},
Method,
};
use std::{
panic,
sync::{Arc, Mutex, MutexGuard},
};

pub(crate) fn wrapper(f: impl FnOnce(&TestEnvironment) -> Result<(), Error>) {
let _ = dotenv::dotenv();
6 changes: 2 additions & 4 deletions src/utils/github_updater.rs
Original file line number Diff line number Diff line change
@@ -77,10 +77,8 @@ fn get_github_fields(path: &str) -> Result<GitHubFields> {
use serde_json::Value;

let body = {
use reqwest::header::USER_AGENT;
use reqwest::{Client, StatusCode};
use std::env;
use std::io::Read;
use reqwest::{blocking::Client, header::USER_AGENT, StatusCode};
use std::{env, io::Read};

let client = Client::new();
let mut body = String::new();
7 changes: 5 additions & 2 deletions src/utils/pubsubhubbub.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
use reqwest::{
blocking::{Client, Response},
Result,
};
use std::collections::HashMap;

use reqwest::*;

fn ping_hub(url: &str) -> Result<Response> {
let mut params = HashMap::with_capacity(2);
params.insert("hub.mode", "publish");
params.insert("hub.url", "https://docs.rs/releases/feed");

let client = Client::new();
client.post(url).form(&params).send()
}