@@ -211,18 +211,25 @@ impl<B: HasExportConfig> WithExportConfig for B {
211
211
}
212
212
213
213
#[ cfg( any( feature = "grpc-tonic" , feature = "http-proto" ) ) ]
214
- fn parse_header_string ( value : & str ) -> impl Iterator < Item = ( & str , & str ) > {
214
+ fn parse_header_string ( value : & str ) -> impl Iterator < Item = ( & str , String ) > {
215
215
value
216
216
. split_terminator ( ',' )
217
217
. map ( str:: trim)
218
218
. filter_map ( parse_header_key_value_string)
219
219
}
220
220
221
221
#[ cfg( any( feature = "grpc-tonic" , feature = "http-proto" ) ) ]
222
- fn parse_header_key_value_string ( key_value_string : & str ) -> Option < ( & str , & str ) > {
222
+ fn parse_header_key_value_string ( key_value_string : & str ) -> Option < ( & str , String ) > {
223
223
key_value_string
224
224
. split_once ( '=' )
225
- . map ( |( key, value) | ( key. trim ( ) , value. trim ( ) ) )
225
+ . map ( |( key, value) | {
226
+ (
227
+ key. trim ( ) ,
228
+ urlencoding:: decode ( value. trim ( ) )
229
+ . unwrap_or_default ( )
230
+ . into_owned ( ) ,
231
+ )
232
+ } )
226
233
. filter ( |( key, value) | !key. is_empty ( ) && !value. is_empty ( ) )
227
234
}
228
235
@@ -280,7 +287,10 @@ mod tests {
280
287
for ( input_str, expected_headers) in test_cases {
281
288
assert_eq ! (
282
289
super :: parse_header_string( input_str) . collect:: <Vec <_>>( ) ,
283
- expected_headers,
290
+ expected_headers
291
+ . into_iter( )
292
+ . map( |( k, v) | ( k, v. to_string( ) ) )
293
+ . collect:: <Vec <_>>( ) ,
284
294
)
285
295
}
286
296
}
@@ -290,6 +300,14 @@ mod tests {
290
300
let test_cases = vec ! [
291
301
// Format: (input_str, expected_header)
292
302
( "k1=v1" , Some ( ( "k1" , "v1" ) ) ) ,
303
+ (
304
+ "Authentication=Basic AAA" ,
305
+ Some ( ( "Authentication" , "Basic AAA" ) ) ,
306
+ ) ,
307
+ (
308
+ "Authentication=Basic%20AAA" ,
309
+ Some ( ( "Authentication" , "Basic AAA" ) ) ,
310
+ ) ,
293
311
( "" , None ) ,
294
312
( "=v1" , None ) ,
295
313
( "k1=" , None ) ,
@@ -298,7 +316,10 @@ mod tests {
298
316
for ( input_str, expected_headers) in test_cases {
299
317
assert_eq ! (
300
318
super :: parse_header_key_value_string( input_str) ,
301
- expected_headers,
319
+ match expected_headers {
320
+ Some ( ( k, v) ) => Some ( ( k, v. to_string( ) ) ) ,
321
+ None => None ,
322
+ }
302
323
)
303
324
}
304
325
}
0 commit comments