@@ -31,14 +31,14 @@ use datafusion::{
3131} ;
3232use log:: { debug, error, info, warn} ;
3333
34+ #[ cfg( feature = "flightsql" ) ]
35+ use crate :: config:: BasicAuth ;
3436use color_eyre:: eyre:: { self , Result } ;
37+ use std:: collections:: HashMap ;
3538use tokio:: sync:: Mutex ;
3639use tokio_stream:: StreamExt ;
3740use tonic:: { transport:: Channel , IntoRequest } ;
3841
39- #[ cfg( feature = "flightsql" ) ]
40- use crate :: config:: BasicAuth ;
41-
4242use crate :: {
4343 config:: FlightSQLConfig , flightsql_benchmarks:: FlightSQLBenchmarkStats , ExecOptions , ExecResult ,
4444} ;
@@ -65,7 +65,11 @@ impl FlightSQLContext {
6565
6666 // TODO - Make this part of `new` method
6767 /// Create FlightSQL client from users FlightSQL config
68- pub async fn create_client ( & self , cli_host : Option < String > ) -> Result < ( ) > {
68+ pub async fn create_client (
69+ & self ,
70+ cli_host : Option < String > ,
71+ cli_headers : Option < HashMap < String , String > > ,
72+ ) -> Result < ( ) > {
6973 let final_url = cli_host. unwrap_or ( self . config . connection_url . clone ( ) ) ;
7074 let url = Box :: leak ( final_url. into_boxed_str ( ) ) ;
7175 info ! ( "Connecting to FlightSQL host: {}" , url) ;
@@ -89,6 +93,14 @@ impl FlightSQLContext {
8993 let encoded_basic = STANDARD . encode ( format ! ( "{username}:{password}" ) ) ;
9094 client. set_header ( "Authorization" , format ! ( "Basic {encoded_basic}" ) )
9195 }
96+
97+ let mut headers = self . config . headers . clone ( ) ;
98+ if let Some ( cli) = cli_headers {
99+ headers. extend ( cli) ;
100+ }
101+ for ( name, value) in headers {
102+ client. set_header ( name, value) ;
103+ }
92104 }
93105 let mut guard = self . client . lock ( ) . await ;
94106 * guard = Some ( client) ;
0 commit comments