Skip to content
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

Andy dev #44

Merged
merged 3 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions icann-rdap-cli/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{

use icann_rdap_client::query::{
qtype::QueryType,
request::{rdap_request, ResponseData},
request::{rdap_url_request, ResponseData},
};
use icann_rdap_common::{cache::HttpData, response::GetSelfLink};
use pct_str::PctString;
Expand All @@ -24,8 +24,9 @@ pub(crate) async fn do_request(
if processing_params.no_cache {
info!("Cache has been disabled.")
}
let query_url = query_type.query_url(base_url)?;
debug!("Requestion RDAP URL {query_url}");
if !processing_params.no_cache {
let query_url = query_type.query_url(base_url)?;
let file_name = format!(
"{}.cache",
PctString::encode(query_url.chars(), URIReserved)
Expand All @@ -49,7 +50,7 @@ pub(crate) async fn do_request(
}
}
}
let response = rdap_request(base_url, query_type, client).await?;
let response = rdap_url_request(&query_url, client).await?;
if !processing_params.no_cache {
if let Some(self_link) = response.rdap.get_self_link() {
if response.http_data.should_cache() {
Expand Down
1 change: 0 additions & 1 deletion icann-rdap-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use std::fmt::Display;

use icann_rdap_common::{cache::HttpData, response::RdapResponseError};
use reqwest::Url;
use thiserror::Error;

pub mod md;
Expand Down
16 changes: 10 additions & 6 deletions icann-rdap-client/src/query/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ use crate::RdapClientError;

use super::qtype::QueryType;

pub async fn rdap_request(
base_url: &str,
query_type: &QueryType,
client: &Client,
) -> Result<ResponseData, RdapClientError> {
let url = query_type.query_url(base_url)?;
pub async fn rdap_url_request(url: &str, client: &Client) -> Result<ResponseData, RdapClientError> {
let response = client.get(url).send().await?.error_for_status()?;
let content_type = response
.headers()
Expand Down Expand Up @@ -71,6 +66,15 @@ pub async fn rdap_request(
}
}

pub async fn rdap_request(
base_url: &str,
query_type: &QueryType,
client: &Client,
) -> Result<ResponseData, RdapClientError> {
let url = query_type.query_url(base_url)?;
rdap_url_request(&url, client).await
}

#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct ResponseData {
pub rdap: RdapResponse,
Expand Down