Skip to content

Commit

Permalink
Prepend user-supplied user-agent
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipleblanc committed Dec 17, 2024
1 parent 2cab60f commit 1eb4463
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/flight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ fn status_to_arrow_error(status: tonic::Status) -> ArrowError {

impl SqlFlightClient {
pub fn new(chan: Channel, api_key: Option<String>, user_agent: Option<String>) -> Self {
let user_agent = user_agent.unwrap_or_else(get_user_agent);
// Prepend the user agent with the provided user agent if it exists
let user_agent = match user_agent {
Some(ua) => format!("{ua} {}", get_user_agent()),
None => get_user_agent(),
};

let mut headers = HashMap::new();
headers.insert("User-Agent".to_string(), user_agent);
Expand Down

0 comments on commit 1eb4463

Please sign in to comment.