File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -214,9 +214,8 @@ pub(crate) const GRPC_TIMEOUT_HEADER: &str = "grpc-timeout";
214214
215215impl MetadataMap {
216216 // Headers reserved by the gRPC protocol.
217- pub ( crate ) const GRPC_RESERVED_HEADERS : [ HeaderName ; 6 ] = [
217+ pub ( crate ) const GRPC_RESERVED_HEADERS : [ HeaderName ; 5 ] = [
218218 HeaderName :: from_static ( "te" ) ,
219- HeaderName :: from_static ( "user-agent" ) ,
220219 HeaderName :: from_static ( "content-type" ) ,
221220 HeaderName :: from_static ( "grpc-message" ) ,
222221 HeaderName :: from_static ( "grpc-message-type" ) ,
Original file line number Diff line number Diff line change @@ -462,6 +462,25 @@ mod tests {
462462 assert ! ( http_request. headers( ) . is_empty( ) ) ;
463463 }
464464
465+ #[ test]
466+ fn preserves_user_agent ( ) {
467+ let mut r = Request :: new ( 1 ) ;
468+
469+ r. metadata_mut ( ) . insert (
470+ MetadataKey :: from_static ( "user-agent" ) ,
471+ MetadataValue :: from_static ( "Custom/1.2.3" ) ,
472+ ) ;
473+
474+ let http_request = r. into_http (
475+ Uri :: default ( ) ,
476+ http:: Method :: POST ,
477+ http:: Version :: HTTP_2 ,
478+ SanitizeHeaders :: Yes ,
479+ ) ;
480+ let user_agent = http_request. headers ( ) . get ( "user-agent" ) . unwrap ( ) ;
481+ assert_eq ! ( user_agent, "Custom/1.2.3" ) ;
482+ }
483+
465484 #[ test]
466485 fn duration_to_grpc_timeout_less_than_second ( ) {
467486 let timeout = Duration :: from_millis ( 500 ) ;
You can’t perform that action at this time.
0 commit comments