alamb commented on code in PR #2309:
URL: https://github.com/apache/arrow-rs/pull/2309#discussion_r937159321
##########
arrow-flight/src/sql/server.rs:
##########
@@ -285,31 +289,38 @@ where
async fn get_flight_info(
&self,
- request: Request<FlightDescriptor>,
+ tonic_request: Request<FlightDescriptor>,
) -> Result<Response<FlightInfo>, Status> {
- let request = request.into_inner();
+ println!("--- get_flight_info ---");
+ for md in tonic_request.metadata().iter() {
+ println!("{:?}", md);
+ }
+ let mut auth = None;
+ if let Some(md) = tonic_request.metadata().get("authorization") {
+ if let Ok(str) = md.to_str() {
+ let authorization = str.to_string();
+ let bearer = "Bearer ";
+ if authorization.starts_with(bearer) {
+ let authorization =
authorization[bearer.len()..].to_string();
+ auth = Some(authorization)
+ }
+ }
+ };
+ let request = tonic_request.into_inner();
let any: prost_types::Any =
prost::Message::decode(&*request.cmd).map_err(decode_error_to_status)?;
if any.is::<CommandStatementQuery>() {
- return self
- .get_flight_info_statement(
- any.unpack()
- .map_err(arrow_error_to_status)?
- .expect("unreachable"),
- request,
- )
- .await;
+ let token = any.unpack()
+ .map_err(arrow_error_to_status)?
+ .expect("unreachable");
Review Comment:
I see you didn't make this change, but given the function returns `Result`
it seems strange here to me to map the error only to `expect()` it -- maybe
something to improve in a follow on PR
##########
arrow-flight/src/sql/server.rs:
##########
@@ -285,31 +289,38 @@ where
async fn get_flight_info(
&self,
- request: Request<FlightDescriptor>,
+ tonic_request: Request<FlightDescriptor>,
) -> Result<Response<FlightInfo>, Status> {
- let request = request.into_inner();
+ println!("--- get_flight_info ---");
+ for md in tonic_request.metadata().iter() {
+ println!("{:?}", md);
+ }
+ let mut auth = None;
+ if let Some(md) = tonic_request.metadata().get("authorization") {
Review Comment:
What if we passed the entire tonic metadata rather than trying to extract
out the `authorization` field specially -- that way downstream users could
process / handle it however was appropriate for their system?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]