File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -655,8 +655,11 @@ impl<S: io::Read + io::Write> TlsStream<S> {
655
655
}
656
656
657
657
/// Returns the negotiated ALPN protocols
658
- pub fn negotiated_alpn ( & self ) -> Result < Option < Vec < u8 > > > {
659
- Ok ( self . 0 . negotiated_alpn ( ) ?)
658
+ pub fn negotiated_alpn ( & self ) -> Result < Option < String > > {
659
+ Ok ( self
660
+ . 0
661
+ . negotiated_alpn ( ) ?
662
+ . map ( |bytes| String :: from_utf8 ( bytes) . unwrap ( ) ) ) //negotiated_alpn always returns valid utf-8
660
663
}
661
664
662
665
/// Shuts down the TLS session.
Original file line number Diff line number Diff line change @@ -424,7 +424,7 @@ mod tests {
424
424
let s = p ! ( TcpStream :: connect( "google.com:443" ) ) ;
425
425
let socket = p ! ( builder. connect( "google.com" , s) ) ;
426
426
427
- assert_eq ! ( p!( socket. negotiated_alpn( ) ) , Some ( b "h2". to_vec ( ) ) ) ;
427
+ assert_eq ! ( p!( socket. negotiated_alpn( ) ) . as_deref ( ) , Some ( "h2" ) ) ;
428
428
}
429
429
430
430
#[ test]
@@ -433,7 +433,7 @@ mod tests {
433
433
let s = p ! ( TcpStream :: connect( "google.com:443" ) ) ;
434
434
let socket = p ! ( builder. connect( "google.com" , s) ) ;
435
435
436
- assert_eq ! ( p!( socket. negotiated_alpn( ) ) , None ) ;
436
+ assert_eq ! ( p!( socket. negotiated_alpn( ) ) . as_deref ( ) , None ) ;
437
437
}
438
438
439
439
#[ test]
You can’t perform that action at this time.
0 commit comments