@@ -13,7 +13,6 @@ use std::time::Duration;
1313use hyper:: header:: { HeaderMap , AUTHORIZATION , CONTENT_LENGTH , CONTENT_TYPE , USER_AGENT } ;
1414use hyper:: Method ;
1515use hyper:: StatusCode ;
16- use itertools:: Itertools ;
1716use mime:: Mime ;
1817use tokio:: time:: sleep;
1918
@@ -414,22 +413,25 @@ impl Read for MultiPartReader<'_> {
414413 }
415414 ( 0 , true , true ) => return Ok ( 0 ) ,
416415 ( n, true , _) if n > 0 => {
416+ use std:: fmt:: Write as _;
417417 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+
418428 let mut c = Cursor :: new ( Vec :: < u8 > :: new ( ) ) ;
419429 //TODO: The first line ending should be omitted for the first part,
420430 // fortunately Google's API serves don't seem to mind.
421431 ( write ! (
422432 & mut c,
423433 "{}--{}{}{}{}{}" ,
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 ,
433435 ) ) ?;
434436 c. rewind ( ) ?;
435437 self . current_part = Some ( ( c, reader) ) ;
0 commit comments