Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

Commit d3851dd

Browse files
committed
Clear the destination HTTPValue before trying to write it.
1 parent 21d6c82 commit d3851dd

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

net/instaweb/http/inflating_fetch.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ bool InflatingFetch::UnGzipValueIfCompressed(const HTTPValue& src,
122122
headers->Remove(HttpAttributes::kContentEncoding, HttpAttributes::kGzip);
123123
headers->SetContentLength(inflated.length());
124124
content.set(inflated.c_str(), inflated.length());
125+
dest->Clear();
125126
dest->Write(content, handler);
126127
dest->SetHeaders(headers);
127128
return true;

net/instaweb/http/inflating_fetch_test.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,9 @@ TEST(StaticInflatingFetchTest, CompressUncompressValue) {
326326
headers.Lookup1(HttpAttributes::kContentEncoding));
327327
compressed_value.ExtractHeaders(&headers, &handler);
328328
HTTPValue uncompressed_value;
329+
ResponseHeaders temp_headers;
330+
temp_headers.Add("a", "b");
331+
uncompressed_value.SetHeaders(&temp_headers);
329332
ASSERT_TRUE(InflatingFetch::UnGzipValueIfCompressed(
330333
compressed_value, &headers, &uncompressed_value, &handler));
331334
uncompressed_value.ExtractContents(&contents);

0 commit comments

Comments
 (0)