| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/filter/gzip_header.h" | 5 #include "net/filter/gzip_header.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "third_party/zlib/zlib.h" | 10 #include "third_party/zlib/zlib.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 extra_length_ += *pos << 8; | 98 extra_length_ += *pos << 8; |
| 99 pos++; | 99 pos++; |
| 100 state_++; | 100 state_++; |
| 101 // We intentionally fall through, because if we have a | 101 // We intentionally fall through, because if we have a |
| 102 // zero-length FEXTRA, we want to check to notice that we're | 102 // zero-length FEXTRA, we want to check to notice that we're |
| 103 // done reading the FEXTRA before we exit this loop... | 103 // done reading the FEXTRA before we exit this loop... |
| 104 | 104 |
| 105 case IN_FEXTRA: { | 105 case IN_FEXTRA: { |
| 106 // Grab the rest of the bytes in the extra field, or as many | 106 // Grab the rest of the bytes in the extra field, or as many |
| 107 // of them as are actually present so far. | 107 // of them as are actually present so far. |
| 108 const int num_extra_bytes = static_cast<const int>(std::min( | 108 const uint16 num_extra_bytes = static_cast<uint16>(std::min( |
| 109 static_cast<ptrdiff_t>(extra_length_), | 109 static_cast<ptrdiff_t>(extra_length_), |
| 110 (end - pos))); | 110 (end - pos))); |
| 111 pos += num_extra_bytes; | 111 pos += num_extra_bytes; |
| 112 extra_length_ -= num_extra_bytes; | 112 extra_length_ -= num_extra_bytes; |
| 113 if ( extra_length_ == 0 ) { | 113 if ( extra_length_ == 0 ) { |
| 114 state_ = IN_FNAME; // advance when we've seen extra_length_ bytes | 114 state_ = IN_FNAME; // advance when we've seen extra_length_ bytes |
| 115 flags_ &= ~FLAG_FEXTRA; // we're done with the FEXTRA stuff | 115 flags_ &= ~FLAG_FEXTRA; // we're done with the FEXTRA stuff |
| 116 } | 116 } |
| 117 break; | 117 break; |
| 118 } | 118 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 172 |
| 173 if ( (state_ > IN_HEADER_OS) && (flags_ == 0) ) { | 173 if ( (state_ > IN_HEADER_OS) && (flags_ == 0) ) { |
| 174 *header_end = reinterpret_cast<const char*>(pos); | 174 *header_end = reinterpret_cast<const char*>(pos); |
| 175 return COMPLETE_HEADER; | 175 return COMPLETE_HEADER; |
| 176 } else { | 176 } else { |
| 177 return INCOMPLETE_HEADER; | 177 return INCOMPLETE_HEADER; |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 | 180 |
| 181 } // namespace net | 181 } // namespace net |
| OLD | NEW |