Skip to content

Commit

Permalink
Remove reqwest dependency and comment out reqwest-dependant code, lea…
Browse files Browse the repository at this point in the history
…ving the option to return to it
  • Loading branch information
Hainish committed Mar 29, 2024
1 parent 61f4b61 commit a8916a0
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 54 deletions.
2 changes: 1 addition & 1 deletion gpapi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository = "https://github.com/EFForg/rs-google-play/tree/master/gpapi"

[dependencies]
prost = "0.12"
reqwest = { version = "0.12", features = ["stream"] }
#reqwest = "0.12"
bytes = "1"
hyper = { version = "0.14", features = ["full"] }
hyper-tls = "0.5"
Expand Down
106 changes: 53 additions & 53 deletions gpapi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ use hyper::header::{HeaderName as HyperHeaderName, HeaderValue as HyperHeaderVal
use hyper::{Body, Client, Method, Request};
use hyper_tls::HttpsConnector;
use prost::Message;
use reqwest::header::{HeaderMap, HeaderValue, HeaderName};
use reqwest::Url;
//use reqwest::header::{HeaderMap, HeaderValue, HeaderName};
//use reqwest::Url;
use tokio_dl_stream_to_disk::AsyncDownload;

use crate::error::{Error as GpapiError, ErrorKind as GpapiErrorKind};
Expand Down Expand Up @@ -114,7 +114,7 @@ pub struct Gpapi {
tos_token: Option<String>,
dfe_cookie: Option<String>,
gsf_id: Option<i64>,
client: Box<reqwest::Client>,
//client: Box<reqwest::Client>,
hyper_client: Box<hyper::Client<HttpsConnector<HttpConnector>>>,
}

Expand Down Expand Up @@ -142,7 +142,7 @@ impl Gpapi {
tos_token: None,
dfe_cookie: None,
gsf_id: None,
client: Box::new(reqwest::Client::new()),
//client: Box::new(reqwest::Client::new()),
hyper_client: Box::new(hyper_client),
}
}
Expand Down Expand Up @@ -874,55 +874,55 @@ impl Gpapi {
Ok(body_bytes)
}

async fn execute_request_helper_reqwest(
&self,
endpoint: &str,
query: Option<HashMap<&str, String>>,
msg: Option<&[u8]>,
headers: HashMap<&str, String>,
fdfe: bool,
) -> Result<Bytes, Box<dyn Error>> {
let mut url = if fdfe {
Url::parse(&format!(
"{}/fdfe/{}",
consts::defaults::DEFAULT_BASE_URL,
endpoint
))?
} else {
Url::parse(&format!(
"{}/{}",
consts::defaults::DEFAULT_BASE_URL,
endpoint
))?
};

if let Some(query) = query {
let mut queries = url.query_pairs_mut();
for (key, val) in query {
queries.append_pair(key, &val);
}
}

let mut reqwest_headers = HeaderMap::new();
for (key, val) in headers {
reqwest_headers.insert(HeaderName::from_bytes(key.as_bytes())?, HeaderValue::from_str(&val)?);
}

let res = {
if let Some(msg) = msg {
(*self.client)
.post(url)
.headers(reqwest_headers)
.body(msg.to_owned())
.send()
.await?
} else {
(*self.client).get(url).headers(reqwest_headers).send().await?
}
};

Ok(res.bytes().await?)
}
//async fn execute_request_helper_reqwest(
// &self,
// endpoint: &str,
// query: Option<HashMap<&str, String>>,
// msg: Option<&[u8]>,
// headers: HashMap<&str, String>,
// fdfe: bool,
//) -> Result<Bytes, Box<dyn Error>> {
// let mut url = if fdfe {
// Url::parse(&format!(
// "{}/fdfe/{}",
// consts::defaults::DEFAULT_BASE_URL,
// endpoint
// ))?
// } else {
// Url::parse(&format!(
// "{}/{}",
// consts::defaults::DEFAULT_BASE_URL,
// endpoint
// ))?
// };

// if let Some(query) = query {
// let mut queries = url.query_pairs_mut();
// for (key, val) in query {
// queries.append_pair(key, &val);
// }
// }

// let mut reqwest_headers = HeaderMap::new();
// for (key, val) in headers {
// reqwest_headers.insert(HeaderName::from_bytes(key.as_bytes())?, HeaderValue::from_str(&val)?);
// }

// let res = {
// if let Some(msg) = msg {
// (*self.client)
// .post(url)
// .headers(reqwest_headers)
// .body(msg.to_owned())
// .send()
// .await?
// } else {
// (*self.client).get(url).headers(reqwest_headers).send().await?
// }
// };

// Ok(res.bytes().await?)
//}

}

Expand Down

0 comments on commit a8916a0

Please sign in to comment.