| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/http/http_chunked_decoder.h" | 5 #include "net/http/http_chunked_decoder.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 namespace net { | 12 namespace net { |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 typedef testing::Test HttpChunkedDecoderTest; | 16 typedef testing::Test HttpChunkedDecoderTest; |
| 17 | 17 |
| 18 void RunTest(const char* inputs[], size_t num_inputs, | 18 void RunTest(const char* inputs[], |
| 19 size_t num_inputs, |
| 19 const char* expected_output, | 20 const char* expected_output, |
| 20 bool expected_eof, | 21 bool expected_eof, |
| 21 int bytes_after_eof) { | 22 int bytes_after_eof) { |
| 22 HttpChunkedDecoder decoder; | 23 HttpChunkedDecoder decoder; |
| 23 EXPECT_FALSE(decoder.reached_eof()); | 24 EXPECT_FALSE(decoder.reached_eof()); |
| 24 | 25 |
| 25 std::string result; | 26 std::string result; |
| 26 | 27 |
| 27 for (size_t i = 0; i < num_inputs; ++i) { | 28 for (size_t i = 0; i < num_inputs; ++i) { |
| 28 std::string input = inputs[i]; | 29 std::string input = inputs[i]; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 50 if (n < 0) { | 51 if (n < 0) { |
| 51 EXPECT_EQ(ERR_INVALID_CHUNKED_ENCODING, n); | 52 EXPECT_EQ(ERR_INVALID_CHUNKED_ENCODING, n); |
| 52 EXPECT_EQ(fail_index, i); | 53 EXPECT_EQ(fail_index, i); |
| 53 return; | 54 return; |
| 54 } | 55 } |
| 55 } | 56 } |
| 56 FAIL(); // We should have failed on the |fail_index| iteration of the loop. | 57 FAIL(); // We should have failed on the |fail_index| iteration of the loop. |
| 57 } | 58 } |
| 58 | 59 |
| 59 TEST(HttpChunkedDecoderTest, Basic) { | 60 TEST(HttpChunkedDecoderTest, Basic) { |
| 60 const char* inputs[] = { | 61 const char* inputs[] = {"B\r\nhello hello\r\n0\r\n\r\n"}; |
| 61 "B\r\nhello hello\r\n0\r\n\r\n" | |
| 62 }; | |
| 63 RunTest(inputs, arraysize(inputs), "hello hello", true, 0); | 62 RunTest(inputs, arraysize(inputs), "hello hello", true, 0); |
| 64 } | 63 } |
| 65 | 64 |
| 66 TEST(HttpChunkedDecoderTest, OneChunk) { | 65 TEST(HttpChunkedDecoderTest, OneChunk) { |
| 67 const char* inputs[] = { | 66 const char* inputs[] = {"5\r\nhello\r\n"}; |
| 68 "5\r\nhello\r\n" | |
| 69 }; | |
| 70 RunTest(inputs, arraysize(inputs), "hello", false, 0); | 67 RunTest(inputs, arraysize(inputs), "hello", false, 0); |
| 71 } | 68 } |
| 72 | 69 |
| 73 TEST(HttpChunkedDecoderTest, Typical) { | 70 TEST(HttpChunkedDecoderTest, Typical) { |
| 74 const char* inputs[] = { | 71 const char* inputs[] = {"5\r\nhello\r\n", "1\r\n \r\n", "5\r\nworld\r\n", |
| 75 "5\r\nhello\r\n", | 72 "0\r\n\r\n"}; |
| 76 "1\r\n \r\n", | |
| 77 "5\r\nworld\r\n", | |
| 78 "0\r\n\r\n" | |
| 79 }; | |
| 80 RunTest(inputs, arraysize(inputs), "hello world", true, 0); | 73 RunTest(inputs, arraysize(inputs), "hello world", true, 0); |
| 81 } | 74 } |
| 82 | 75 |
| 83 TEST(HttpChunkedDecoderTest, Incremental) { | 76 TEST(HttpChunkedDecoderTest, Incremental) { |
| 84 const char* inputs[] = { | 77 const char* inputs[] = {"5", "\r", "\n", "hello", "\r", "\n", |
| 85 "5", | 78 "0", "\r", "\n", "\r", "\n"}; |
| 86 "\r", | |
| 87 "\n", | |
| 88 "hello", | |
| 89 "\r", | |
| 90 "\n", | |
| 91 "0", | |
| 92 "\r", | |
| 93 "\n", | |
| 94 "\r", | |
| 95 "\n" | |
| 96 }; | |
| 97 RunTest(inputs, arraysize(inputs), "hello", true, 0); | 79 RunTest(inputs, arraysize(inputs), "hello", true, 0); |
| 98 } | 80 } |
| 99 | 81 |
| 100 // Same as above, but group carriage returns with previous input. | 82 // Same as above, but group carriage returns with previous input. |
| 101 TEST(HttpChunkedDecoderTest, Incremental2) { | 83 TEST(HttpChunkedDecoderTest, Incremental2) { |
| 102 const char* inputs[] = { | 84 const char* inputs[] = {"5\r", "\n", "hello\r", "\n", "0\r", "\n\r", "\n"}; |
| 103 "5\r", | |
| 104 "\n", | |
| 105 "hello\r", | |
| 106 "\n", | |
| 107 "0\r", | |
| 108 "\n\r", | |
| 109 "\n" | |
| 110 }; | |
| 111 RunTest(inputs, arraysize(inputs), "hello", true, 0); | 85 RunTest(inputs, arraysize(inputs), "hello", true, 0); |
| 112 } | 86 } |
| 113 | 87 |
| 114 TEST(HttpChunkedDecoderTest, LF_InsteadOf_CRLF) { | 88 TEST(HttpChunkedDecoderTest, LF_InsteadOf_CRLF) { |
| 115 // Compatibility: [RFC 2616 - Invalid] | 89 // Compatibility: [RFC 2616 - Invalid] |
| 116 // {Firefox3} - Valid | 90 // {Firefox3} - Valid |
| 117 // {IE7, Safari3.1, Opera9.51} - Invalid | 91 // {IE7, Safari3.1, Opera9.51} - Invalid |
| 118 const char* inputs[] = { | 92 const char* inputs[] = {"5\nhello\n", "1\n \n", "5\nworld\n", "0\n\n"}; |
| 119 "5\nhello\n", | |
| 120 "1\n \n", | |
| 121 "5\nworld\n", | |
| 122 "0\n\n" | |
| 123 }; | |
| 124 RunTest(inputs, arraysize(inputs), "hello world", true, 0); | 93 RunTest(inputs, arraysize(inputs), "hello world", true, 0); |
| 125 } | 94 } |
| 126 | 95 |
| 127 TEST(HttpChunkedDecoderTest, Extensions) { | 96 TEST(HttpChunkedDecoderTest, Extensions) { |
| 128 const char* inputs[] = { | 97 const char* inputs[] = {"5;x=0\r\nhello\r\n", "0;y=\"2 \"\r\n\r\n"}; |
| 129 "5;x=0\r\nhello\r\n", | |
| 130 "0;y=\"2 \"\r\n\r\n" | |
| 131 }; | |
| 132 RunTest(inputs, arraysize(inputs), "hello", true, 0); | 98 RunTest(inputs, arraysize(inputs), "hello", true, 0); |
| 133 } | 99 } |
| 134 | 100 |
| 135 TEST(HttpChunkedDecoderTest, Trailers) { | 101 TEST(HttpChunkedDecoderTest, Trailers) { |
| 136 const char* inputs[] = { | 102 const char* inputs[] = {"5\r\nhello\r\n", "0\r\n", "Foo: 1\r\n", "Bar: 2\r\n", |
| 137 "5\r\nhello\r\n", | 103 "\r\n"}; |
| 138 "0\r\n", | |
| 139 "Foo: 1\r\n", | |
| 140 "Bar: 2\r\n", | |
| 141 "\r\n" | |
| 142 }; | |
| 143 RunTest(inputs, arraysize(inputs), "hello", true, 0); | 104 RunTest(inputs, arraysize(inputs), "hello", true, 0); |
| 144 } | 105 } |
| 145 | 106 |
| 146 TEST(HttpChunkedDecoderTest, TrailersUnfinished) { | 107 TEST(HttpChunkedDecoderTest, TrailersUnfinished) { |
| 147 const char* inputs[] = { | 108 const char* inputs[] = {"5\r\nhello\r\n", "0\r\n", "Foo: 1\r\n"}; |
| 148 "5\r\nhello\r\n", | |
| 149 "0\r\n", | |
| 150 "Foo: 1\r\n" | |
| 151 }; | |
| 152 RunTest(inputs, arraysize(inputs), "hello", false, 0); | 109 RunTest(inputs, arraysize(inputs), "hello", false, 0); |
| 153 } | 110 } |
| 154 | 111 |
| 155 TEST(HttpChunkedDecoderTest, InvalidChunkSize_TooBig) { | 112 TEST(HttpChunkedDecoderTest, InvalidChunkSize_TooBig) { |
| 156 const char* inputs[] = { | 113 const char* inputs[] = { |
| 157 // This chunked body is not terminated. | 114 // This chunked body is not terminated. |
| 158 // However we will fail decoding because the chunk-size | 115 // However we will fail decoding because the chunk-size |
| 159 // number is larger than we can handle. | 116 // number is larger than we can handle. |
| 160 "48469410265455838241\r\nhello\r\n", | 117 "48469410265455838241\r\nhello\r\n", "0\r\n\r\n"}; |
| 161 "0\r\n\r\n" | |
| 162 }; | |
| 163 RunTestUntilFailure(inputs, arraysize(inputs), 0); | 118 RunTestUntilFailure(inputs, arraysize(inputs), 0); |
| 164 } | 119 } |
| 165 | 120 |
| 166 TEST(HttpChunkedDecoderTest, InvalidChunkSize_0X) { | 121 TEST(HttpChunkedDecoderTest, InvalidChunkSize_0X) { |
| 167 const char* inputs[] = { | 122 const char* inputs[] = {// Compatibility [RFC 2616 - Invalid]: |
| 168 // Compatibility [RFC 2616 - Invalid]: | 123 // {Safari3.1, IE7} - Invalid |
| 169 // {Safari3.1, IE7} - Invalid | 124 // {Firefox3, Opera 9.51} - Valid |
| 170 // {Firefox3, Opera 9.51} - Valid | 125 "0x5\r\nhello\r\n", "0\r\n\r\n"}; |
| 171 "0x5\r\nhello\r\n", | |
| 172 "0\r\n\r\n" | |
| 173 }; | |
| 174 RunTestUntilFailure(inputs, arraysize(inputs), 0); | 126 RunTestUntilFailure(inputs, arraysize(inputs), 0); |
| 175 } | 127 } |
| 176 | 128 |
| 177 TEST(HttpChunkedDecoderTest, ChunkSize_TrailingSpace) { | 129 TEST(HttpChunkedDecoderTest, ChunkSize_TrailingSpace) { |
| 178 const char* inputs[] = { | 130 const char* inputs[] = {// Compatibility [RFC 2616 - Invalid]: |
| 179 // Compatibility [RFC 2616 - Invalid]: | 131 // {IE7, Safari3.1, Firefox3, Opera 9.51} - Valid |
| 180 // {IE7, Safari3.1, Firefox3, Opera 9.51} - Valid | 132 // |
| 181 // | 133 // At least yahoo.com depends on this being valid. |
| 182 // At least yahoo.com depends on this being valid. | 134 "5 \r\nhello\r\n", "0\r\n\r\n"}; |
| 183 "5 \r\nhello\r\n", | |
| 184 "0\r\n\r\n" | |
| 185 }; | |
| 186 RunTest(inputs, arraysize(inputs), "hello", true, 0); | 135 RunTest(inputs, arraysize(inputs), "hello", true, 0); |
| 187 } | 136 } |
| 188 | 137 |
| 189 TEST(HttpChunkedDecoderTest, InvalidChunkSize_TrailingTab) { | 138 TEST(HttpChunkedDecoderTest, InvalidChunkSize_TrailingTab) { |
| 190 const char* inputs[] = { | 139 const char* inputs[] = {// Compatibility [RFC 2616 - Invalid]: |
| 191 // Compatibility [RFC 2616 - Invalid]: | 140 // {IE7, Safari3.1, Firefox3, Opera 9.51} - Valid |
| 192 // {IE7, Safari3.1, Firefox3, Opera 9.51} - Valid | 141 "5\t\r\nhello\r\n", "0\r\n\r\n"}; |
| 193 "5\t\r\nhello\r\n", | |
| 194 "0\r\n\r\n" | |
| 195 }; | |
| 196 RunTestUntilFailure(inputs, arraysize(inputs), 0); | 142 RunTestUntilFailure(inputs, arraysize(inputs), 0); |
| 197 } | 143 } |
| 198 | 144 |
| 199 TEST(HttpChunkedDecoderTest, InvalidChunkSize_TrailingFormFeed) { | 145 TEST(HttpChunkedDecoderTest, InvalidChunkSize_TrailingFormFeed) { |
| 200 const char* inputs[] = { | 146 const char* inputs[] = {// Compatibility [RFC 2616- Invalid]: |
| 201 // Compatibility [RFC 2616- Invalid]: | 147 // {Safari3.1} - Invalid |
| 202 // {Safari3.1} - Invalid | 148 // {IE7, Firefox3, Opera 9.51} - Valid |
| 203 // {IE7, Firefox3, Opera 9.51} - Valid | 149 "5\f\r\nhello\r\n", "0\r\n\r\n"}; |
| 204 "5\f\r\nhello\r\n", | |
| 205 "0\r\n\r\n" | |
| 206 }; | |
| 207 RunTestUntilFailure(inputs, arraysize(inputs), 0); | 150 RunTestUntilFailure(inputs, arraysize(inputs), 0); |
| 208 } | 151 } |
| 209 | 152 |
| 210 TEST(HttpChunkedDecoderTest, InvalidChunkSize_TrailingVerticalTab) { | 153 TEST(HttpChunkedDecoderTest, InvalidChunkSize_TrailingVerticalTab) { |
| 211 const char* inputs[] = { | 154 const char* inputs[] = {// Compatibility [RFC 2616 - Invalid]: |
| 212 // Compatibility [RFC 2616 - Invalid]: | 155 // {Safari 3.1} - Invalid |
| 213 // {Safari 3.1} - Invalid | 156 // {IE7, Firefox3, Opera 9.51} - Valid |
| 214 // {IE7, Firefox3, Opera 9.51} - Valid | 157 "5\v\r\nhello\r\n", "0\r\n\r\n"}; |
| 215 "5\v\r\nhello\r\n", | |
| 216 "0\r\n\r\n" | |
| 217 }; | |
| 218 RunTestUntilFailure(inputs, arraysize(inputs), 0); | 158 RunTestUntilFailure(inputs, arraysize(inputs), 0); |
| 219 } | 159 } |
| 220 | 160 |
| 221 TEST(HttpChunkedDecoderTest, InvalidChunkSize_TrailingNonHexDigit) { | 161 TEST(HttpChunkedDecoderTest, InvalidChunkSize_TrailingNonHexDigit) { |
| 222 const char* inputs[] = { | 162 const char* inputs[] = {// Compatibility [RFC 2616 - Invalid]: |
| 223 // Compatibility [RFC 2616 - Invalid]: | 163 // {Safari 3.1} - Invalid |
| 224 // {Safari 3.1} - Invalid | 164 // {IE7, Firefox3, Opera 9.51} - Valid |
| 225 // {IE7, Firefox3, Opera 9.51} - Valid | 165 "5H\r\nhello\r\n", "0\r\n\r\n"}; |
| 226 "5H\r\nhello\r\n", | |
| 227 "0\r\n\r\n" | |
| 228 }; | |
| 229 RunTestUntilFailure(inputs, arraysize(inputs), 0); | 166 RunTestUntilFailure(inputs, arraysize(inputs), 0); |
| 230 } | 167 } |
| 231 | 168 |
| 232 TEST(HttpChunkedDecoderTest, InvalidChunkSize_LeadingSpace) { | 169 TEST(HttpChunkedDecoderTest, InvalidChunkSize_LeadingSpace) { |
| 233 const char* inputs[] = { | 170 const char* inputs[] = {// Compatibility [RFC 2616 - Invalid]: |
| 234 // Compatibility [RFC 2616 - Invalid]: | 171 // {IE7} - Invalid |
| 235 // {IE7} - Invalid | 172 // {Safari 3.1, Firefox3, Opera 9.51} - Valid |
| 236 // {Safari 3.1, Firefox3, Opera 9.51} - Valid | 173 " 5\r\nhello\r\n", "0\r\n\r\n"}; |
| 237 " 5\r\nhello\r\n", | |
| 238 "0\r\n\r\n" | |
| 239 }; | |
| 240 RunTestUntilFailure(inputs, arraysize(inputs), 0); | 174 RunTestUntilFailure(inputs, arraysize(inputs), 0); |
| 241 } | 175 } |
| 242 | 176 |
| 243 TEST(HttpChunkedDecoderTest, InvalidLeadingSeparator) { | 177 TEST(HttpChunkedDecoderTest, InvalidLeadingSeparator) { |
| 244 const char* inputs[] = { | 178 const char* inputs[] = {"\r\n5\r\nhello\r\n", "0\r\n\r\n"}; |
| 245 "\r\n5\r\nhello\r\n", | |
| 246 "0\r\n\r\n" | |
| 247 }; | |
| 248 RunTestUntilFailure(inputs, arraysize(inputs), 0); | 179 RunTestUntilFailure(inputs, arraysize(inputs), 0); |
| 249 } | 180 } |
| 250 | 181 |
| 251 TEST(HttpChunkedDecoderTest, InvalidChunkSize_NoSeparator) { | 182 TEST(HttpChunkedDecoderTest, InvalidChunkSize_NoSeparator) { |
| 252 const char* inputs[] = { | 183 const char* inputs[] = {"5\r\nhello", "1\r\n \r\n", "0\r\n\r\n"}; |
| 253 "5\r\nhello", | |
| 254 "1\r\n \r\n", | |
| 255 "0\r\n\r\n" | |
| 256 }; | |
| 257 RunTestUntilFailure(inputs, arraysize(inputs), 1); | 184 RunTestUntilFailure(inputs, arraysize(inputs), 1); |
| 258 } | 185 } |
| 259 | 186 |
| 260 TEST(HttpChunkedDecoderTest, InvalidChunkSize_Negative) { | 187 TEST(HttpChunkedDecoderTest, InvalidChunkSize_Negative) { |
| 261 const char* inputs[] = { | 188 const char* inputs[] = {"8\r\n12345678\r\n-5\r\nhello\r\n", "0\r\n\r\n"}; |
| 262 "8\r\n12345678\r\n-5\r\nhello\r\n", | |
| 263 "0\r\n\r\n" | |
| 264 }; | |
| 265 RunTestUntilFailure(inputs, arraysize(inputs), 0); | 189 RunTestUntilFailure(inputs, arraysize(inputs), 0); |
| 266 } | 190 } |
| 267 | 191 |
| 268 TEST(HttpChunkedDecoderTest, InvalidChunkSize_Plus) { | 192 TEST(HttpChunkedDecoderTest, InvalidChunkSize_Plus) { |
| 269 const char* inputs[] = { | 193 const char* inputs[] = {// Compatibility [RFC 2616 - Invalid]: |
| 270 // Compatibility [RFC 2616 - Invalid]: | 194 // {IE7, Safari 3.1} - Invalid |
| 271 // {IE7, Safari 3.1} - Invalid | 195 // {Firefox3, Opera 9.51} - Valid |
| 272 // {Firefox3, Opera 9.51} - Valid | 196 "+5\r\nhello\r\n", "0\r\n\r\n"}; |
| 273 "+5\r\nhello\r\n", | |
| 274 "0\r\n\r\n" | |
| 275 }; | |
| 276 RunTestUntilFailure(inputs, arraysize(inputs), 0); | 197 RunTestUntilFailure(inputs, arraysize(inputs), 0); |
| 277 } | 198 } |
| 278 | 199 |
| 279 TEST(HttpChunkedDecoderTest, InvalidConsecutiveCRLFs) { | 200 TEST(HttpChunkedDecoderTest, InvalidConsecutiveCRLFs) { |
| 280 const char* inputs[] = { | 201 const char* inputs[] = {"5\r\nhello\r\n", "\r\n\r\n\r\n\r\n", "0\r\n\r\n"}; |
| 281 "5\r\nhello\r\n", | |
| 282 "\r\n\r\n\r\n\r\n", | |
| 283 "0\r\n\r\n" | |
| 284 }; | |
| 285 RunTestUntilFailure(inputs, arraysize(inputs), 1); | 202 RunTestUntilFailure(inputs, arraysize(inputs), 1); |
| 286 } | 203 } |
| 287 | 204 |
| 288 TEST(HttpChunkedDecoderTest, ExcessiveChunkLen) { | 205 TEST(HttpChunkedDecoderTest, ExcessiveChunkLen) { |
| 289 const char* inputs[] = { | 206 const char* inputs[] = {"c0000000\r\nhello\r\n"}; |
| 290 "c0000000\r\nhello\r\n" | |
| 291 }; | |
| 292 RunTestUntilFailure(inputs, arraysize(inputs), 0); | 207 RunTestUntilFailure(inputs, arraysize(inputs), 0); |
| 293 } | 208 } |
| 294 | 209 |
| 295 TEST(HttpChunkedDecoderTest, BasicExtraData) { | 210 TEST(HttpChunkedDecoderTest, BasicExtraData) { |
| 296 const char* inputs[] = { | 211 const char* inputs[] = {"5\r\nhello\r\n0\r\n\r\nextra bytes"}; |
| 297 "5\r\nhello\r\n0\r\n\r\nextra bytes" | |
| 298 }; | |
| 299 RunTest(inputs, arraysize(inputs), "hello", true, 11); | 212 RunTest(inputs, arraysize(inputs), "hello", true, 11); |
| 300 } | 213 } |
| 301 | 214 |
| 302 TEST(HttpChunkedDecoderTest, IncrementalExtraData) { | 215 TEST(HttpChunkedDecoderTest, IncrementalExtraData) { |
| 303 const char* inputs[] = { | 216 const char* inputs[] = {"5", "\r", "\n", "hello", "\r", "\n", |
| 304 "5", | 217 "0", "\r", "\n", "\r", "\nextra bytes"}; |
| 305 "\r", | |
| 306 "\n", | |
| 307 "hello", | |
| 308 "\r", | |
| 309 "\n", | |
| 310 "0", | |
| 311 "\r", | |
| 312 "\n", | |
| 313 "\r", | |
| 314 "\nextra bytes" | |
| 315 }; | |
| 316 RunTest(inputs, arraysize(inputs), "hello", true, 11); | 218 RunTest(inputs, arraysize(inputs), "hello", true, 11); |
| 317 } | 219 } |
| 318 | 220 |
| 319 TEST(HttpChunkedDecoderTest, MultipleExtraDataBlocks) { | 221 TEST(HttpChunkedDecoderTest, MultipleExtraDataBlocks) { |
| 320 const char* inputs[] = { | 222 const char* inputs[] = {"5\r\nhello\r\n0\r\n\r\nextra", " bytes"}; |
| 321 "5\r\nhello\r\n0\r\n\r\nextra", | |
| 322 " bytes" | |
| 323 }; | |
| 324 RunTest(inputs, arraysize(inputs), "hello", true, 11); | 223 RunTest(inputs, arraysize(inputs), "hello", true, 11); |
| 325 } | 224 } |
| 326 | 225 |
| 327 // Test when the line with the chunk length is too long. | 226 // Test when the line with the chunk length is too long. |
| 328 TEST(HttpChunkedDecoderTest, LongChunkLengthLine) { | 227 TEST(HttpChunkedDecoderTest, LongChunkLengthLine) { |
| 329 int big_chunk_length = HttpChunkedDecoder::kMaxLineBufLen; | 228 int big_chunk_length = HttpChunkedDecoder::kMaxLineBufLen; |
| 330 scoped_ptr<char[]> big_chunk(new char[big_chunk_length + 1]); | 229 scoped_ptr<char[]> big_chunk(new char[big_chunk_length + 1]); |
| 331 memset(big_chunk.get(), '0', big_chunk_length); | 230 memset(big_chunk.get(), '0', big_chunk_length); |
| 332 big_chunk[big_chunk_length] = 0; | 231 big_chunk[big_chunk_length] = 0; |
| 333 const char* inputs[] = { | 232 const char* inputs[] = {big_chunk.get(), "5"}; |
| 334 big_chunk.get(), | |
| 335 "5" | |
| 336 }; | |
| 337 RunTestUntilFailure(inputs, arraysize(inputs), 1); | 233 RunTestUntilFailure(inputs, arraysize(inputs), 1); |
| 338 } | 234 } |
| 339 | 235 |
| 340 // Test when the extension portion of the line with the chunk length is too | 236 // Test when the extension portion of the line with the chunk length is too |
| 341 // long. | 237 // long. |
| 342 TEST(HttpChunkedDecoderTest, LongLengthLengthLine) { | 238 TEST(HttpChunkedDecoderTest, LongLengthLengthLine) { |
| 343 int big_chunk_length = HttpChunkedDecoder::kMaxLineBufLen; | 239 int big_chunk_length = HttpChunkedDecoder::kMaxLineBufLen; |
| 344 scoped_ptr<char[]> big_chunk(new char[big_chunk_length + 1]); | 240 scoped_ptr<char[]> big_chunk(new char[big_chunk_length + 1]); |
| 345 memset(big_chunk.get(), '0', big_chunk_length); | 241 memset(big_chunk.get(), '0', big_chunk_length); |
| 346 big_chunk[big_chunk_length] = 0; | 242 big_chunk[big_chunk_length] = 0; |
| 347 const char* inputs[] = { | 243 const char* inputs[] = {"5;", big_chunk.get()}; |
| 348 "5;", | |
| 349 big_chunk.get() | |
| 350 }; | |
| 351 RunTestUntilFailure(inputs, arraysize(inputs), 1); | 244 RunTestUntilFailure(inputs, arraysize(inputs), 1); |
| 352 } | 245 } |
| 353 | 246 |
| 354 } // namespace | 247 } // namespace |
| 355 | 248 |
| 356 } // namespace net | 249 } // namespace net |
| OLD | NEW |