@@ -13,7 +13,6 @@ use std::time::Duration;
13
13
use hyper:: header:: { HeaderMap , AUTHORIZATION , CONTENT_LENGTH , CONTENT_TYPE , USER_AGENT } ;
14
14
use hyper:: Method ;
15
15
use hyper:: StatusCode ;
16
- use itertools:: Itertools ;
17
16
use mime:: Mime ;
18
17
use tokio:: time:: sleep;
19
18
@@ -414,22 +413,25 @@ impl Read for MultiPartReader<'_> {
414
413
}
415
414
( 0 , true , true ) => return Ok ( 0 ) ,
416
415
( n, true , _) if n > 0 => {
416
+ use std:: fmt:: Write as _;
417
417
let ( headers, reader) = self . raw_parts . remove ( 0 ) ;
418
+
419
+ let mut encoded_headers = String :: new ( ) ;
420
+ for ( k, v) in & headers {
421
+ if !encoded_headers. is_empty ( ) {
422
+ encoded_headers. push_str ( LINE_ENDING ) ;
423
+ }
424
+
425
+ write ! ( encoded_headers, "{}: {}" , k, v. to_str( ) . unwrap( ) ) . unwrap ( ) ;
426
+ }
427
+
418
428
let mut c = Cursor :: new ( Vec :: < u8 > :: new ( ) ) ;
419
429
//TODO: The first line ending should be omitted for the first part,
420
430
// fortunately Google's API serves don't seem to mind.
421
431
( write ! (
422
432
& mut c,
423
433
"{}--{}{}{}{}{}" ,
424
- LINE_ENDING ,
425
- BOUNDARY ,
426
- LINE_ENDING ,
427
- headers
428
- . iter( )
429
- . map( |( k, v) | format!( "{}: {}" , k, v. to_str( ) . unwrap( ) ) )
430
- . join( LINE_ENDING ) ,
431
- LINE_ENDING ,
432
- LINE_ENDING ,
434
+ LINE_ENDING , BOUNDARY , LINE_ENDING , encoded_headers, LINE_ENDING , LINE_ENDING ,
433
435
) ) ?;
434
436
c. rewind ( ) ?;
435
437
self . current_part = Some ( ( c, reader) ) ;
0 commit comments