@@ -1288,13 +1288,6 @@ impl Client {
12881288 body
12891289 } else {
12901290 head. headers . remove ( header:: TRANSFER_ENCODING ) ;
1291- // If we know there's body coming, set a content-length.
1292- // But only if the method normally has a body.
1293- // GET, HEAD, and CONNECT are assumed empty.
1294- if !is_method_assumed_empty ( & head. subject . 0 ) {
1295- head. headers
1296- . insert ( header:: CONTENT_LENGTH , HeaderValue :: from_static ( "0" ) ) ;
1297- }
12981291 return Encoder :: length ( 0 ) ;
12991292 } ;
13001293
@@ -1368,11 +1361,12 @@ impl Client {
13681361 // So instead of sending a "chunked" body with a 0-chunk,
13691362 // assume no body here. If you *must* send a body,
13701363 // set the headers explicitly.
1371- if is_method_assumed_empty ( & head. subject . 0 ) {
1372- Some ( Encoder :: length ( 0 ) )
1373- } else {
1374- te. insert ( HeaderValue :: from_static ( "chunked" ) ) ;
1375- Some ( Encoder :: chunked ( ) )
1364+ match head. subject . 0 {
1365+ Method :: GET | Method :: HEAD | Method :: CONNECT => Some ( Encoder :: length ( 0 ) ) ,
1366+ _ => {
1367+ te. insert ( HeaderValue :: from_static ( "chunked" ) ) ;
1368+ Some ( Encoder :: chunked ( ) )
1369+ }
13761370 }
13771371 } else {
13781372 None
@@ -1474,11 +1468,6 @@ impl Client {
14741468 }
14751469}
14761470
1477- #[ cfg( feature = "client" ) ]
1478- fn is_method_assumed_empty ( method : & Method ) -> bool {
1479- matches ! ( method, & Method :: GET | & Method :: HEAD | & Method :: CONNECT )
1480- }
1481-
14821471#[ cfg( feature = "client" ) ]
14831472fn set_content_length ( headers : & mut HeaderMap , len : u64 ) -> Encoder {
14841473 // At this point, there should not be a valid Content-Length
0 commit comments