Permalink
Browse files

Clear the destination HTTPValue before trying to write it.

  • Loading branch information...
jmarantz committed Jan 19, 2016
1 parent 21d6c82 commit d3851dd3824d0aa93a2430618e9c61b37511d254
Showing with 4 additions and 0 deletions.
  1. +1 −0 net/instaweb/http/inflating_fetch.cc
  2. +3 −0 net/instaweb/http/inflating_fetch_test.cc
@@ -122,6 +122,7 @@ bool InflatingFetch::UnGzipValueIfCompressed(const HTTPValue& src,
headers->Remove(HttpAttributes::kContentEncoding, HttpAttributes::kGzip);
headers->SetContentLength(inflated.length());
content.set(inflated.c_str(), inflated.length());
dest->Clear();
dest->Write(content, handler);
dest->SetHeaders(headers);
return true;
@@ -326,6 +326,9 @@ TEST(StaticInflatingFetchTest, CompressUncompressValue) {
headers.Lookup1(HttpAttributes::kContentEncoding));
compressed_value.ExtractHeaders(&headers, &handler);
HTTPValue uncompressed_value;
ResponseHeaders temp_headers;
temp_headers.Add("a", "b");
uncompressed_value.SetHeaders(&temp_headers);
ASSERT_TRUE(InflatingFetch::UnGzipValueIfCompressed(
compressed_value, &headers, &uncompressed_value, &handler));
uncompressed_value.ExtractContents(&contents);

0 comments on commit d3851dd

Please sign in to comment.