| 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 30 matching lines...) Expand all Loading... |
| 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 #pragma once | 47 #pragma once |
| 48 | 48 |
| 49 #include <string> | 49 #include <string> |
| 50 | 50 |
| 51 #include "net/base/net_api.h" | 51 #include "net/base/net_export.h" |
| 52 | 52 |
| 53 namespace net { | 53 namespace net { |
| 54 | 54 |
| 55 // From RFC2617 section 3.6.1, the chunked transfer coding is defined as: | 55 // From RFC2617 section 3.6.1, the chunked transfer coding is defined as: |
| 56 // | 56 // |
| 57 // Chunked-Body = *chunk | 57 // Chunked-Body = *chunk |
| 58 // last-chunk | 58 // last-chunk |
| 59 // trailer | 59 // trailer |
| 60 // CRLF | 60 // CRLF |
| 61 // chunk = chunk-size [ chunk-extension ] CRLF | 61 // chunk = chunk-size [ chunk-extension ] CRLF |
| 62 // chunk-data CRLF | 62 // chunk-data CRLF |
| 63 // chunk-size = 1*HEX | 63 // chunk-size = 1*HEX |
| 64 // last-chunk = 1*("0") [ chunk-extension ] CRLF | 64 // last-chunk = 1*("0") [ chunk-extension ] CRLF |
| 65 // | 65 // |
| 66 // chunk-extension = *( ";" chunk-ext-name [ "=" chunk-ext-val ] ) | 66 // chunk-extension = *( ";" chunk-ext-name [ "=" chunk-ext-val ] ) |
| 67 // chunk-ext-name = token | 67 // chunk-ext-name = token |
| 68 // chunk-ext-val = token | quoted-string | 68 // chunk-ext-val = token | quoted-string |
| 69 // chunk-data = chunk-size(OCTET) | 69 // chunk-data = chunk-size(OCTET) |
| 70 // trailer = *(entity-header CRLF) | 70 // trailer = *(entity-header CRLF) |
| 71 // | 71 // |
| 72 // The chunk-size field is a string of hex digits indicating the size of the | 72 // The chunk-size field is a string of hex digits indicating the size of the |
| 73 // chunk. The chunked encoding is ended by any chunk whose size is zero, | 73 // chunk. The chunked encoding is ended by any chunk whose size is zero, |
| 74 // followed by the trailer, which is terminated by an empty line. | 74 // followed by the trailer, which is terminated by an empty line. |
| 75 // | 75 // |
| 76 // NOTE: This implementation does not bother to parse trailers since they are | 76 // NOTE: This implementation does not bother to parse trailers since they are |
| 77 // not used on the web. | 77 // not used on the web. |
| 78 // | 78 // |
| 79 class NET_TEST HttpChunkedDecoder { | 79 class NET_EXPORT_PRIVATE HttpChunkedDecoder { |
| 80 public: | 80 public: |
| 81 HttpChunkedDecoder(); | 81 HttpChunkedDecoder(); |
| 82 | 82 |
| 83 // Indicates that a previous call to FilterBuf encountered the final CRLF. | 83 // Indicates that a previous call to FilterBuf encountered the final CRLF. |
| 84 bool reached_eof() const { return reached_eof_; } | 84 bool reached_eof() const { return reached_eof_; } |
| 85 | 85 |
| 86 // Returns the number of bytes after the final CRLF. | 86 // Returns the number of bytes after the final CRLF. |
| 87 int bytes_after_eof() const { return bytes_after_eof_; } | 87 int bytes_after_eof() const { return bytes_after_eof_; } |
| 88 | 88 |
| 89 // Called to filter out the chunk markers from buf and to check for end-of- | 89 // Called to filter out the chunk markers from buf and to check for end-of- |
| (...skipping 30 matching lines...) Expand all Loading... |
| 120 bool reached_eof_; | 120 bool reached_eof_; |
| 121 | 121 |
| 122 // The number of unfiltered bytes after the final CRLF, either extraneous | 122 // The number of unfiltered bytes after the final CRLF, either extraneous |
| 123 // data or the first part of the next response in a pipelined stream. | 123 // data or the first part of the next response in a pipelined stream. |
| 124 int bytes_after_eof_; | 124 int bytes_after_eof_; |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 } // namespace net | 127 } // namespace net |
| 128 | 128 |
| 129 #endif // NET_HTTP_HTTP_CHUNKED_DECODER_H_ | 129 #endif // NET_HTTP_HTTP_CHUNKED_DECODER_H_ |
| OLD | NEW |