From 68b745055e85cc466a0c867e87eacb43539baaa4 Mon Sep 17 00:00:00 2001 From: "mbelshe@chromium.org" Date: Fri, 16 Apr 2010 21:04:55 +0000 Subject: Fix crash in WriteSocket() when sending Settings frames and compression is enabled. We need better unit tests for the compressed-frame testing. Filed bug 41805 to implement those. BUG=41803 TEST=NONE Review URL: http://codereview.chromium.org/1648014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44819 0039d316-1c4b-4281-b951-d872f2087c98 --- net/spdy/spdy_framer.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'net/spdy/spdy_framer.cc') diff --git a/net/spdy/spdy_framer.cc b/net/spdy/spdy_framer.cc index 65ef2e5..dc1f856 100644 --- a/net/spdy/spdy_framer.cc +++ b/net/spdy/spdy_framer.cc @@ -888,6 +888,24 @@ SpdyFrame* SpdyFramer::DuplicateFrame(const SpdyFrame* frame) { return new_frame; } +bool SpdyFramer::IsCompressible(const SpdyFrame* frame) const { + // The important frames to compress are those which contain large + // amounts of compressible data - namely the headers in the SYN_STREAM + // and SYN_REPLY. + // TODO(mbelshe): Reconcile this with the spec when the spec is + // explicit about which frames compress and which do not. + if (frame->is_control_frame()) { + const SpdyControlFrame* control_frame = + reinterpret_cast(frame); + return control_frame->type() == SYN_STREAM || + control_frame->type() == SYN_REPLY; + } + + const SpdyDataFrame* data_frame = + reinterpret_cast(frame); + return (data_frame->flags() & DATA_FLAG_COMPRESSED) != 0; +} + void SpdyFramer::set_enable_compression(bool value) { enable_compression_ = value; } -- cgit v1.1