Add user-agent header to Solana rust client requests
This commit is contained in:
parent
d6a28cb7a8
commit
558dd53025
|
@ -12,7 +12,7 @@ use {
|
|||
log::*,
|
||||
reqwest::{
|
||||
self,
|
||||
header::{CONTENT_TYPE, RETRY_AFTER},
|
||||
header::{self, CONTENT_TYPE, RETRY_AFTER},
|
||||
StatusCode,
|
||||
},
|
||||
std::{
|
||||
|
@ -46,8 +46,17 @@ impl HttpSender {
|
|||
///
|
||||
/// The URL is an HTTP URL, usually for port 8899.
|
||||
pub fn new_with_timeout<U: ToString>(url: U, timeout: Duration) -> Self {
|
||||
let mut default_headers = header::HeaderMap::new();
|
||||
let user_agent_string =
|
||||
format!("rust-solana-client/{}", solana_version::Version::default());
|
||||
default_headers.append(
|
||||
header::USER_AGENT,
|
||||
header::HeaderValue::from_str(user_agent_string.as_str()).unwrap(),
|
||||
);
|
||||
|
||||
let client = Arc::new(
|
||||
reqwest::Client::builder()
|
||||
.default_headers(default_headers)
|
||||
.timeout(timeout)
|
||||
.build()
|
||||
.expect("build rpc client"),
|
||||
|
|
Loading…
Reference in New Issue