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

Fix #39 #42

Merged
merged 1 commit into from
Dec 11, 2023
Merged

Fix #39 #42

merged 1 commit into from
Dec 11, 2023

Conversation

ddnomad
Copy link
Contributor

@ddnomad ddnomad commented Dec 11, 2023

Implemented changes proposed in #39. Please note that this change breaks compatibility with previous version by removing (now redundant) content_length, content_type and url fields here:

pub content_length: Option<u64>,
pub content_type: Option<String>,
pub url: Url,

Removed fields should now be accessible as part of a new http_data field on icann_rdap_client::RdapClientError::ParsingError error variant (content_length, content_type and host fields respectively).

Minimal reproducible example of a (now supported) use case:

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let client_config = icann_rdap_common::client::ClientConfig::builder()
        .https_only(false)
        .follow_redirects(false)
        .build();
    
    let client = icann_rdap_common::client::create_client(&client_config)
        .expect("Failed to build RDAP library client");
    
    let query = icann_rdap_client::query::qtype::QueryType::from_str("10.0.0.0/8")?;

    // Will result in `icann_rdap_client::RdapClientError::ParsingError` because of
    // `follow_redirects(false)` in `client_config`
    let error = icann_rdap_client::query::request::rdap_request(
        "http://127.0.0.1/rdapbootstrap", // Locally running RDAP bootstrap server
        &query,
        client
    )
    .await
    .unwrap_err(); // PR adds `Debug` derive on `icann_rdap_client::query::request::ResponseData`

    match error {
	icann_rdap_client::RdapClientError::ParsingError(info) => {
		println!(
			"Should now send a request to: {}",
			info.http_data.location.expect("No location, strange!")
		)
	}
	_ => panic!("Something went wrong!"),
    }
}

Do let me know if any issues.

@anewton1998 anewton1998 merged commit 0ba698e into icann:dev Dec 11, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants