v0.2.11-pre.004
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-offchain-transport-lib/src/http_client.rs
|
||||
// version: 2
|
||||
// version: 3
|
||||
|
||||
//! Crate-wide hardened REST client used internally by off-chain capability adapters.
|
||||
|
||||
@@ -71,12 +71,24 @@ impl crate::HttpGetRequest {
|
||||
return std::result::Result::Ok(());
|
||||
}
|
||||
|
||||
/// Reports whether a named header is present without exposing its value in tests.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn has_header_for_test(&self, name: &'static str) -> bool {
|
||||
return self.headers.contains_key(name);
|
||||
}
|
||||
|
||||
/// Creates a plain-HTTP request for loopback-only deterministic unit tests.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn new_test_http(url: &str) -> ksp_core_lib::Result<Self> {
|
||||
return Self::parse(url, true);
|
||||
}
|
||||
|
||||
/// Returns the constructed URL only to deterministic in-crate tests; production diagnostics remain redacted.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn url_for_test(&self) -> &reqwest::Url {
|
||||
return &self.url;
|
||||
}
|
||||
|
||||
fn parse(url: &str, allow_http_for_tests: bool) -> ksp_core_lib::Result<Self> {
|
||||
let parsed_result = reqwest::Url::parse(url);
|
||||
let parsed = match parsed_result {
|
||||
|
||||
Reference in New Issue
Block a user