diff options
-rw-r--r-- | net/spdy/spdy_framer.cc | 5 | ||||
-rw-r--r-- | net/spdy/spdy_framer_test.cc | 23 |
2 files changed, 27 insertions, 1 deletions
diff --git a/net/spdy/spdy_framer.cc b/net/spdy/spdy_framer.cc index 1d1da73..94ab6d1 100644 --- a/net/spdy/spdy_framer.cc +++ b/net/spdy/spdy_framer.cc @@ -705,7 +705,10 @@ static void WriteZ(const base::StringPiece& data, } else { rv = deflate(out, Z_PARTIAL_FLUSH); } - DCHECK_EQ(Z_OK, rv); + if (!data.empty()) { + // If we didn't provide any data then zlib will return Z_BUF_ERROR. + DCHECK_EQ(Z_OK, rv); + } DCHECK_EQ(0u, out->avail_in); DCHECK_LT(0u, out->avail_out); } diff --git a/net/spdy/spdy_framer_test.cc b/net/spdy/spdy_framer_test.cc index c5117c6..98320f6 100644 --- a/net/spdy/spdy_framer_test.cc +++ b/net/spdy/spdy_framer_test.cc @@ -944,6 +944,29 @@ TEST_P(SpdyFramerTest, BasicCompression) { SpdyFrame::kHeaderSize + uncompressed_frame->length())); } +TEST_P(SpdyFramerTest, CompressEmptyHeaders) { + // See crbug.com/172383 + SpdyHeaderBlock headers; + headers["server"] = "SpdyServer 1.0"; + headers["date"] = "Mon 12 Jan 2009 12:12:12 PST"; + headers["status"] = "200"; + headers["version"] = "HTTP/1.1"; + headers["content-type"] = "text/html"; + headers["content-length"] = "12"; + headers["x-empty-header"] = ""; + + SpdyFramer framer(spdy_version_); + framer.set_enable_compression(true); + scoped_ptr<SpdySynStreamControlFrame> frame1( + framer.CreateSynStream(1, // stream id + 0, // associated stream id + 1, // priority + 0, // credential slot + CONTROL_FLAG_NONE, + true, // compress + &headers)); +} + TEST_P(SpdyFramerTest, Basic) { const unsigned char kV2Input[] = { 0x80, spdy_version_, 0x00, 0x01, // SYN Stream #1 |