OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/base/gzip_filter.h" | 5 #include "net/base/gzip_filter.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "net/base/gzip_header.h" | 8 #include "net/base/gzip_header.h" |
9 #include "third_party/zlib/zlib.h" | 9 #include "third_party/zlib/zlib.h" |
10 | 10 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 } | 190 } |
191 | 191 |
192 return Filter::FILTER_ERROR; | 192 return Filter::FILTER_ERROR; |
193 } | 193 } |
194 | 194 |
195 Filter::FilterStatus GZipFilter::DoInflate(char* dest_buffer, int* dest_len) { | 195 Filter::FilterStatus GZipFilter::DoInflate(char* dest_buffer, int* dest_len) { |
196 // Make sure we have both valid input data and output buffer. | 196 // Make sure we have both valid input data and output buffer. |
197 if (!dest_buffer || !dest_len || *dest_len <= 0) // output | 197 if (!dest_buffer || !dest_len || *dest_len <= 0) // output |
198 return Filter::FILTER_ERROR; | 198 return Filter::FILTER_ERROR; |
199 | 199 |
200 if (!next_stream_data_ || stream_data_len_ <= 0) // input | 200 if (!next_stream_data_ || stream_data_len_ <= 0) { // input |
201 return Filter::FILTER_ERROR; | 201 *dest_len = 0; |
| 202 return Filter::FILTER_NEED_MORE_DATA; |
| 203 } |
202 | 204 |
203 // Fill in zlib control block | 205 // Fill in zlib control block |
204 zlib_stream_.get()->next_in = bit_cast<Bytef*>(next_stream_data_); | 206 zlib_stream_.get()->next_in = bit_cast<Bytef*>(next_stream_data_); |
205 zlib_stream_.get()->avail_in = stream_data_len_; | 207 zlib_stream_.get()->avail_in = stream_data_len_; |
206 zlib_stream_.get()->next_out = bit_cast<Bytef*>(dest_buffer); | 208 zlib_stream_.get()->next_out = bit_cast<Bytef*>(dest_buffer); |
207 zlib_stream_.get()->avail_out = *dest_len; | 209 zlib_stream_.get()->avail_out = *dest_len; |
208 | 210 |
209 int inflate_code = MOZ_Z_inflate(zlib_stream_.get(), Z_NO_FLUSH); | 211 int inflate_code = MOZ_Z_inflate(zlib_stream_.get(), Z_NO_FLUSH); |
210 int bytesWritten = *dest_len - zlib_stream_.get()->avail_out; | 212 int bytesWritten = *dest_len - zlib_stream_.get()->avail_out; |
211 | 213 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 if (footer_bytes_expected > 0) { | 286 if (footer_bytes_expected > 0) { |
285 int footer_byte_avail = std::min(footer_bytes_expected, stream_data_len_); | 287 int footer_byte_avail = std::min(footer_bytes_expected, stream_data_len_); |
286 stream_data_len_ -= footer_byte_avail; | 288 stream_data_len_ -= footer_byte_avail; |
287 next_stream_data_ += footer_byte_avail; | 289 next_stream_data_ += footer_byte_avail; |
288 gzip_footer_bytes_ += footer_byte_avail; | 290 gzip_footer_bytes_ += footer_byte_avail; |
289 | 291 |
290 if (stream_data_len_ == 0) | 292 if (stream_data_len_ == 0) |
291 next_stream_data_ = NULL; | 293 next_stream_data_ = NULL; |
292 } | 294 } |
293 } | 295 } |
OLD | NEW |