@@ -1288,13 +1288,6 @@ impl Client {
1288
1288
body
1289
1289
} else {
1290
1290
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
- }
1298
1291
return Encoder :: length ( 0 ) ;
1299
1292
} ;
1300
1293
@@ -1368,11 +1361,12 @@ impl Client {
1368
1361
// So instead of sending a "chunked" body with a 0-chunk,
1369
1362
// assume no body here. If you *must* send a body,
1370
1363
// 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
+ }
1376
1370
}
1377
1371
} else {
1378
1372
None
@@ -1474,11 +1468,6 @@ impl Client {
1474
1468
}
1475
1469
}
1476
1470
1477
- #[ cfg( feature = "client" ) ]
1478
- fn is_method_assumed_empty ( method : & Method ) -> bool {
1479
- matches ! ( method, & Method :: GET | & Method :: HEAD | & Method :: CONNECT )
1480
- }
1481
-
1482
1471
#[ cfg( feature = "client" ) ]
1483
1472
fn set_content_length ( headers : & mut HeaderMap , len : u64 ) -> Encoder {
1484
1473
// At this point, there should not be a valid Content-Length
0 commit comments