Fix Httpclient headers from being modified accidentally (#17808)

(cherry picked from commit f1ce173283)
This commit is contained in:
Joey
2021-04-20 23:42:04 -06:00
committed by narimiran
parent f48daa29f6
commit 5618a34d61

View File

@@ -958,12 +958,15 @@ proc format(client: HttpClient | AsyncHttpClient,
proc override(fallback, override: HttpHeaders): HttpHeaders =
# Right-biased map union for `HttpHeaders`
if override.isNil:
return fallback
result = newHttpHeaders()
# Copy by value
result.table[] = fallback.table[]
if override.isNil:
# Return the copy of fallback so it does not get modified
return result
for k, vs in override.table:
result[k] = vs