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 // The GZipHeader class allows you to parse a gzip header, such as you | 5 // The GZipHeader class allows you to parse a gzip header, such as you |
6 // might find at the beginning of a file compressed by gzip (ie, a .gz | 6 // might find at the beginning of a file compressed by gzip (ie, a .gz |
7 // file), or at the beginning of an HTTP response that uses a gzip | 7 // file), or at the beginning of an HTTP response that uses a gzip |
8 // Content-Encoding. See RFC 1952 for the specification for the gzip | 8 // Content-Encoding. See RFC 1952 for the specification for the gzip |
9 // header. | 9 // header. |
10 // | 10 // |
11 // The model is that you call ReadMore() for each chunk of bytes | 11 // The model is that you call ReadMore() for each chunk of bytes |
12 // you've read from a file or socket. | 12 // you've read from a file or socket. |
13 // | 13 // |
14 | 14 |
15 #ifndef NET_FILTER_GZIP_HEADER_H_ | 15 #ifndef NET_FILTER_GZIP_HEADER_H_ |
16 #define NET_FILTER_GZIP_HEADER_H_ | 16 #define NET_FILTER_GZIP_HEADER_H_ |
17 | 17 |
18 #include "base/basictypes.h" | 18 #include <stdint.h> |
| 19 |
| 20 #include "base/macros.h" |
19 | 21 |
20 namespace net { | 22 namespace net { |
21 | 23 |
22 class GZipHeader { | 24 class GZipHeader { |
23 public: | 25 public: |
24 enum Status { | 26 enum Status { |
25 INCOMPLETE_HEADER, // don't have all the bits yet... | 27 INCOMPLETE_HEADER, // don't have all the bits yet... |
26 COMPLETE_HEADER, // complete, valid header | 28 COMPLETE_HEADER, // complete, valid header |
27 INVALID_HEADER, // found something invalid in the header | 29 INVALID_HEADER, // found something invalid in the header |
28 }; | 30 }; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 IN_FNAME, | 75 IN_FNAME, |
74 | 76 |
75 IN_FCOMMENT, | 77 IN_FCOMMENT, |
76 | 78 |
77 IN_FHCRC_BYTE_0, | 79 IN_FHCRC_BYTE_0, |
78 IN_FHCRC_BYTE_1, | 80 IN_FHCRC_BYTE_1, |
79 | 81 |
80 IN_DONE, | 82 IN_DONE, |
81 }; | 83 }; |
82 | 84 |
83 static const uint8 magic[]; // gzip magic header | 85 static const uint8_t magic[]; // gzip magic header |
84 | 86 |
85 int state_; // our current State in the parsing FSM: an int so we can ++ | 87 int state_; // our current State in the parsing FSM: an int so we can ++ |
86 uint8 flags_; // the flags byte of the header ("FLG" in the RFC) | 88 uint8_t flags_; // the flags byte of the header ("FLG" in the RFC) |
87 uint16 extra_length_; // how much of the "extra field" we have yet to read | 89 uint16_t extra_length_; // how much of the "extra field" we have yet to read |
88 | 90 |
89 DISALLOW_COPY_AND_ASSIGN(GZipHeader); | 91 DISALLOW_COPY_AND_ASSIGN(GZipHeader); |
90 }; | 92 }; |
91 | 93 |
92 } // namespace net | 94 } // namespace net |
93 | 95 |
94 #endif // NET_FILTER_GZIP_HEADER_H_ | 96 #endif // NET_FILTER_GZIP_HEADER_H_ |
OLD | NEW |