@@ -21,7 +21,7 @@ use super::{Decoder, Encode, EncodedBuf, Encoder, Http1Transaction, ParseContext
21
21
use crate :: body:: DecodedLength ;
22
22
#[ cfg( feature = "server" ) ]
23
23
use crate :: common:: time:: Time ;
24
- use crate :: headers:: connection_keep_alive ;
24
+ use crate :: headers;
25
25
use crate :: proto:: { BodyLength , MessageHead } ;
26
26
#[ cfg( feature = "server" ) ]
27
27
use crate :: rt:: Sleep ;
@@ -657,7 +657,7 @@ where
657
657
let outgoing_is_keep_alive = head
658
658
. headers
659
659
. get ( CONNECTION )
660
- . map_or ( false , connection_keep_alive) ;
660
+ . map_or ( false , headers :: connection_keep_alive) ;
661
661
662
662
if !outgoing_is_keep_alive {
663
663
match head. version {
@@ -680,12 +680,22 @@ where
680
680
// If we know the remote speaks an older version, we try to fix up any messages
681
681
// to work with our older peer.
682
682
fn enforce_version ( & mut self , head : & mut MessageHead < T :: Outgoing > ) {
683
- if let Version :: HTTP_10 = self . state . version {
684
- // Fixes response or connection when keep-alive header is not present
685
- self . fix_keep_alive ( head) ;
686
- // If the remote only knows HTTP/1.0, we should force ourselves
687
- // to do only speak HTTP/1.0 as well.
688
- head. version = Version :: HTTP_10 ;
683
+ match self . state . version {
684
+ Version :: HTTP_10 => {
685
+ // Fixes response or connection when keep-alive header is not present
686
+ self . fix_keep_alive ( head) ;
687
+ // If the remote only knows HTTP/1.0, we should force ourselves
688
+ // to do only speak HTTP/1.0 as well.
689
+ head. version = Version :: HTTP_10 ;
690
+ } ,
691
+ Version :: HTTP_11 => {
692
+ if let KA :: Disabled = self . state . keep_alive . status ( ) {
693
+ head. headers
694
+ . insert ( CONNECTION , HeaderValue :: from_static ( "close" ) ) ;
695
+ }
696
+
697
+ } ,
698
+ _ => ( ) ,
689
699
}
690
700
// If the remote speaks HTTP/1.1, then it *should* be fine with
691
701
// both HTTP/1.0 and HTTP/1.1 from us. So again, we just let
0 commit comments