Skip to content

Commit

Permalink
Add user-agent header to Solana rust client requests (solana-labs#26274)
Browse files Browse the repository at this point in the history
(cherry picked from commit 558dd53)

Co-authored-by: steveluscher <[email protected]>
  • Loading branch information
mergify[bot] and steveluscher authored Jun 28, 2022
1 parent b437a9d commit 972edc9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion client/src/http_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use {
log::*,
reqwest::{
self,
header::{CONTENT_TYPE, RETRY_AFTER},
header::{self, CONTENT_TYPE, RETRY_AFTER},
StatusCode,
},
std::{
Expand Down Expand Up @@ -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"),
Expand Down

0 comments on commit 972edc9

Please sign in to comment.