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

Unified Diff: net/filter/gzip_source_stream.h

Issue 2604233002: Fix bug in deflate code. (Closed)
Patch Set: Cleanups Created 4 years 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') | net/filter/gzip_source_stream.cc » ('J')
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..e11a7964da16874635fd4878205aa80eda29aa27 100644
--- a/net/filter/gzip_source_stream.h
+++ b/net/filter/gzip_source_stream.h
@@ -44,6 +44,15 @@ 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
xunjieli 2017/01/03 16:21:17 For future reference, could you add a link to bug
mmenke 2017/01/03 18:25:42 SGTM, Done.
+ // 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.
+ STATE_REPLAY_DATA,
// The input stream is being decoded.
STATE_COMPRESSED_BODY,
// Gzip footer of the input stream is being processed.
@@ -84,9 +93,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 +108,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') | net/filter/gzip_source_stream.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698