Skip to content

Commit b116935

Browse files
Drop dependency on itertools
1 parent 22240c0 commit b116935

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

google-apis-common/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ http = "1"
2020
http-body-util = "0.1"
2121
hyper = { version = "1", features = ["client", "http2"] }
2222
hyper-util = { version = "0.1", features = ["client-legacy", "http2"] }
23-
itertools = "0.13"
2423
mime = "0.3"
2524
percent-encoding = "2"
2625
serde = { version = "1", features = ["derive"] }

google-apis-common/src/lib.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use std::time::Duration;
1313
use hyper::header::{HeaderMap, AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, USER_AGENT};
1414
use hyper::Method;
1515
use hyper::StatusCode;
16-
use itertools::Itertools;
1716
use mime::Mime;
1817
use tokio::time::sleep;
1918

@@ -414,22 +413,25 @@ impl<'a> Read for MultiPartReader<'a> {
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

Comments
 (0)