Skip to content

Commit 4b1b789

Browse files
committed
Adjust .with_headers to support multiple header pairs
1 parent 72f3fda commit 4b1b789

File tree

1 file changed

+6
-6
lines changed
  • opentelemetry-otlp/src/exporter/http

1 file changed

+6
-6
lines changed

opentelemetry-otlp/src/exporter/http/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -449,13 +449,13 @@ impl<B: HasHttpConfig> WithHttpConfig for B {
449449

450450
fn with_headers(mut self, headers: HashMap<String, String>) -> Self {
451451
// headers will be wrapped, so we must do some logic to unwrap first.
452-
self.http_client_config()
452+
let http_client_headers = self
453+
.http_client_config()
453454
.headers
454-
.iter_mut()
455-
.zip(headers)
456-
.for_each(|(http_client_headers, (key, value))| {
457-
http_client_headers.insert(key, super::url_decode(&value).unwrap_or(value));
458-
});
455+
.get_or_insert(HashMap::new());
456+
headers.into_iter().for_each(|(key, value)| {
457+
http_client_headers.insert(key, super::url_decode(&value).unwrap_or(value));
458+
});
459459
self
460460
}
461461
}

0 commit comments

Comments
 (0)