OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Derived from: | 5 // Derived from: |
6 // mozilla/netwerk/protocol/http/src/nsHttpChunkedDecoder.h | 6 // mozilla/netwerk/protocol/http/src/nsHttpChunkedDecoder.h |
7 // The license block is: | 7 // The license block is: |
8 /* ***** BEGIN LICENSE BLOCK ***** | 8 /* ***** BEGIN LICENSE BLOCK ***** |
9 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 9 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
10 * | 10 * |
(...skipping 28 matching lines...) Expand all Loading... |
39 * and other provisions required by the GPL or the LGPL. If you do not delete | 39 * and other provisions required by the GPL or the LGPL. If you do not delete |
40 * the provisions above, a recipient may use your version of this file under | 40 * the provisions above, a recipient may use your version of this file under |
41 * the terms of any one of the MPL, the GPL or the LGPL. | 41 * the terms of any one of the MPL, the GPL or the LGPL. |
42 * | 42 * |
43 * ***** END LICENSE BLOCK ***** */ | 43 * ***** END LICENSE BLOCK ***** */ |
44 | 44 |
45 #ifndef NET_HTTP_HTTP_CHUNKED_DECODER_H_ | 45 #ifndef NET_HTTP_HTTP_CHUNKED_DECODER_H_ |
46 #define NET_HTTP_HTTP_CHUNKED_DECODER_H_ | 46 #define NET_HTTP_HTTP_CHUNKED_DECODER_H_ |
47 | 47 |
48 #include <stddef.h> | 48 #include <stddef.h> |
| 49 #include <stdint.h> |
49 | 50 |
50 #include <string> | 51 #include <string> |
51 | 52 |
52 #include "net/base/net_export.h" | 53 #include "net/base/net_export.h" |
53 | 54 |
54 namespace net { | 55 namespace net { |
55 | 56 |
56 // From RFC2617 section 3.6.1, the chunked transfer coding is defined as: | 57 // From RFC2617 section 3.6.1, the chunked transfer coding is defined as: |
57 // | 58 // |
58 // Chunked-Body = *chunk | 59 // Chunked-Body = *chunk |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 101 |
101 private: | 102 private: |
102 // Scans |buf| for the next chunk delimiter. This method returns the number | 103 // Scans |buf| for the next chunk delimiter. This method returns the number |
103 // of bytes consumed from |buf|. If found, |chunk_remaining_| holds the | 104 // of bytes consumed from |buf|. If found, |chunk_remaining_| holds the |
104 // value for the next chunk size. | 105 // value for the next chunk size. |
105 int ScanForChunkRemaining(const char* buf, int buf_len); | 106 int ScanForChunkRemaining(const char* buf, int buf_len); |
106 | 107 |
107 // Converts string |start| of length |len| to a numeric value. | 108 // Converts string |start| of length |len| to a numeric value. |
108 // |start| is a string of type "chunk-size" (hex string). | 109 // |start| is a string of type "chunk-size" (hex string). |
109 // If the conversion succeeds, returns true and places the result in |out|. | 110 // If the conversion succeeds, returns true and places the result in |out|. |
110 static bool ParseChunkSize(const char* start, int len, int* out); | 111 static bool ParseChunkSize(const char* start, int len, int64_t* out); |
111 | 112 |
112 // Indicates the number of bytes remaining for the current chunk. | 113 // Indicates the number of bytes remaining for the current chunk. |
113 int chunk_remaining_; | 114 int64_t chunk_remaining_; |
114 | 115 |
115 // A small buffer used to store a partial chunk marker. | 116 // A small buffer used to store a partial chunk marker. |
116 std::string line_buf_; | 117 std::string line_buf_; |
117 | 118 |
118 // True if waiting for the terminal CRLF of a chunk's data. | 119 // True if waiting for the terminal CRLF of a chunk's data. |
119 bool chunk_terminator_remaining_; | 120 bool chunk_terminator_remaining_; |
120 | 121 |
121 // Set to true when FilterBuf encounters the last-chunk. | 122 // Set to true when FilterBuf encounters the last-chunk. |
122 bool reached_last_chunk_; | 123 bool reached_last_chunk_; |
123 | 124 |
124 // Set to true when FilterBuf encounters the final CRLF. | 125 // Set to true when FilterBuf encounters the final CRLF. |
125 bool reached_eof_; | 126 bool reached_eof_; |
126 | 127 |
127 // The number of extraneous unfiltered bytes after the final CRLF. | 128 // The number of extraneous unfiltered bytes after the final CRLF. |
128 int bytes_after_eof_; | 129 int bytes_after_eof_; |
129 }; | 130 }; |
130 | 131 |
131 } // namespace net | 132 } // namespace net |
132 | 133 |
133 #endif // NET_HTTP_HTTP_CHUNKED_DECODER_H_ | 134 #endif // NET_HTTP_HTTP_CHUNKED_DECODER_H_ |
OLD | NEW |