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> | |
50 | 49 |
51 #include <string> | 50 #include <string> |
52 | 51 |
53 #include "net/base/net_export.h" | 52 #include "net/base/net_export.h" |
54 | 53 |
55 namespace net { | 54 namespace net { |
56 | 55 |
57 // From RFC2617 section 3.6.1, the chunked transfer coding is defined as: | 56 // From RFC2617 section 3.6.1, the chunked transfer coding is defined as: |
58 // | 57 // |
59 // Chunked-Body = *chunk | 58 // Chunked-Body = *chunk |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 100 |
102 private: | 101 private: |
103 // Scans |buf| for the next chunk delimiter. This method returns the number | 102 // Scans |buf| for the next chunk delimiter. This method returns the number |
104 // of bytes consumed from |buf|. If found, |chunk_remaining_| holds the | 103 // of bytes consumed from |buf|. If found, |chunk_remaining_| holds the |
105 // value for the next chunk size. | 104 // value for the next chunk size. |
106 int ScanForChunkRemaining(const char* buf, int buf_len); | 105 int ScanForChunkRemaining(const char* buf, int buf_len); |
107 | 106 |
108 // Converts string |start| of length |len| to a numeric value. | 107 // Converts string |start| of length |len| to a numeric value. |
109 // |start| is a string of type "chunk-size" (hex string). | 108 // |start| is a string of type "chunk-size" (hex string). |
110 // If the conversion succeeds, returns true and places the result in |out|. | 109 // If the conversion succeeds, returns true and places the result in |out|. |
111 static bool ParseChunkSize(const char* start, int len, int64_t* out); | 110 static bool ParseChunkSize(const char* start, int len, int* out); |
112 | 111 |
113 // Indicates the number of bytes remaining for the current chunk. | 112 // Indicates the number of bytes remaining for the current chunk. |
114 int64_t chunk_remaining_; | 113 int chunk_remaining_; |
115 | 114 |
116 // A small buffer used to store a partial chunk marker. | 115 // A small buffer used to store a partial chunk marker. |
117 std::string line_buf_; | 116 std::string line_buf_; |
118 | 117 |
119 // True if waiting for the terminal CRLF of a chunk's data. | 118 // True if waiting for the terminal CRLF of a chunk's data. |
120 bool chunk_terminator_remaining_; | 119 bool chunk_terminator_remaining_; |
121 | 120 |
122 // Set to true when FilterBuf encounters the last-chunk. | 121 // Set to true when FilterBuf encounters the last-chunk. |
123 bool reached_last_chunk_; | 122 bool reached_last_chunk_; |
124 | 123 |
125 // Set to true when FilterBuf encounters the final CRLF. | 124 // Set to true when FilterBuf encounters the final CRLF. |
126 bool reached_eof_; | 125 bool reached_eof_; |
127 | 126 |
128 // The number of extraneous unfiltered bytes after the final CRLF. | 127 // The number of extraneous unfiltered bytes after the final CRLF. |
129 int bytes_after_eof_; | 128 int bytes_after_eof_; |
130 }; | 129 }; |
131 | 130 |
132 } // namespace net | 131 } // namespace net |
133 | 132 |
134 #endif // NET_HTTP_HTTP_CHUNKED_DECODER_H_ | 133 #endif // NET_HTTP_HTTP_CHUNKED_DECODER_H_ |
OLD | NEW |