Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(433)

Unified Diff: net/filter/gzip_source_stream.h

Issue 2604233002: Fix bug in deflate code. (Closed)
Patch Set: Revert bypassing replay state Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/filter/gzip_source_stream.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/filter/gzip_source_stream.h
diff --git a/net/filter/gzip_source_stream.h b/net/filter/gzip_source_stream.h
index 46f296af0c326cd999ffabada9a5454238b8a561..1a038049351a78751bb9d4b89fe3389df4e69434 100644
--- a/net/filter/gzip_source_stream.h
+++ b/net/filter/gzip_source_stream.h
@@ -9,8 +9,6 @@
#include <string>
#include "base/macros.h"
-#include "base/memory/ref_counted.h"
-#include "net/base/io_buffer.h"
#include "net/base/net_export.h"
#include "net/filter/filter_source_stream.h"
#include "net/filter/gzip_header.h"
@@ -44,6 +42,16 @@ class NET_EXPORT_PRIVATE GzipSourceStream : public FilterSourceStream {
STATE_START,
// Gzip header of the input stream is being processed.
STATE_GZIP_HEADER,
+ // Deflate responses may or may not have a zlib header. In this state until
+ // enough has been inflated that this stream most likely has a zlib header,
+ // or until a zlib header has been added. Data is appended to |replay_data_|
+ // in case it needs to be replayed after adding a header.
+ STATE_SNIFFING_DEFLATE_HEADER,
+ // If a zlib header has to be added to the response, this state will replay
+ // data passed to inflate before it was determined that no zlib header was
+ // present.
+ // See https://crbug.com/677001
+ STATE_REPLAY_DATA,
// The input stream is being decoded.
STATE_COMPRESSED_BODY,
// Gzip footer of the input stream is being processed.
@@ -84,9 +92,10 @@ class NET_EXPORT_PRIVATE GzipSourceStream : public FilterSourceStream {
// FilterData(), with InsertZlibHeader() being the exception as a workaround.
std::unique_ptr<z_stream> zlib_stream_;
- // A flag used by FilterData() to record whether we've successfully added
- // a zlib header to this stream.
- bool zlib_header_added_;
+ // While in STATE_SNIFFING_DEFLATE_HEADER, it may be determined that a zlib
+ // header needs to be added, and all received data needs to be replayed. In
+ // that case, this buffer holds the data to be replayed.
+ std::string replay_data_;
// Used to parse the gzip header in gzip stream.
// It is used when the decoding mode is GZIP_SOURCE_STREAM_GZIP.
@@ -98,6 +107,9 @@ class NET_EXPORT_PRIVATE GzipSourceStream : public FilterSourceStream {
// Tracks the state of the input stream.
InputState input_state_;
+ // Used when replaying data.
+ InputState replay_state_;
+
DISALLOW_COPY_AND_ASSIGN(GzipSourceStream);
};
« no previous file with comments | « no previous file | net/filter/gzip_source_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698