Chromium Code Reviews| 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); |
| }; |