| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <iostream> | 6 #include <iostream> |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 header_buffer_valid_ = true; | 495 header_buffer_valid_ = true; |
| 496 DCHECK_NE(header_stream_id_, SpdyFramer::kInvalidStream); | 496 DCHECK_NE(header_stream_id_, SpdyFramer::kInvalidStream); |
| 497 } | 497 } |
| 498 | 498 |
| 499 // Override the default buffer size (16K). Call before using the framer! | 499 // Override the default buffer size (16K). Call before using the framer! |
| 500 void set_header_buffer_size(size_t header_buffer_size) { | 500 void set_header_buffer_size(size_t header_buffer_size) { |
| 501 header_buffer_size_ = header_buffer_size; | 501 header_buffer_size_ = header_buffer_size; |
| 502 header_buffer_.reset(new char[header_buffer_size]); | 502 header_buffer_.reset(new char[header_buffer_size]); |
| 503 } | 503 } |
| 504 | 504 |
| 505 // Largest control frame that the SPDY implementation sends, including the |
| 506 // size of the header. |
| 507 static size_t sent_control_frame_max_size() { |
| 508 return SpdyFramer::kMaxControlFrameSize; |
| 509 } |
| 510 |
| 505 static size_t header_data_chunk_max_size() { | 511 static size_t header_data_chunk_max_size() { |
| 506 return SpdyFramer::kHeaderDataChunkMaxSize; | 512 return SpdyFramer::kHeaderDataChunkMaxSize; |
| 507 } | 513 } |
| 508 | 514 |
| 509 SpdyFramer framer_; | 515 SpdyFramer framer_; |
| 510 bool use_compression_; | 516 bool use_compression_; |
| 511 | 517 |
| 512 // Counters from the visitor callbacks. | 518 // Counters from the visitor callbacks. |
| 513 int error_count_; | 519 int error_count_; |
| 514 int syn_frame_count_; | 520 int syn_frame_count_; |
| (...skipping 2625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3140 { | 3146 { |
| 3141 // Test framing in a case such that a PUSH_PROMISE frame, with one byte of | 3147 // Test framing in a case such that a PUSH_PROMISE frame, with one byte of |
| 3142 // padding, cannot hold all the data payload, which is overflowed to the | 3148 // padding, cannot hold all the data payload, which is overflowed to the |
| 3143 // consecutive CONTINUATION frame. | 3149 // consecutive CONTINUATION frame. |
| 3144 SpdyFramer framer(spdy_version_); | 3150 SpdyFramer framer(spdy_version_); |
| 3145 framer.set_enable_compression(false); | 3151 framer.set_enable_compression(false); |
| 3146 const char kDescription[] = | 3152 const char kDescription[] = |
| 3147 "PUSH_PROMISE and CONTINUATION frames with one byte of padding"; | 3153 "PUSH_PROMISE and CONTINUATION frames with one byte of padding"; |
| 3148 | 3154 |
| 3149 const unsigned char kPartialPushPromiseFrameData[] = { | 3155 const unsigned char kPartialPushPromiseFrameData[] = { |
| 3150 0x00, 0x03, 0xf6, 0x05, // PUSH_PROMISE | 3156 0x00, 0x03, 0xf7, 0x05, // PUSH_PROMISE |
| 3151 0x08, 0x00, 0x00, 0x00, // PADDED | 3157 0x08, 0x00, 0x00, 0x00, // PADDED |
| 3152 0x2a, 0x00, 0x00, 0x00, // Stream 42 | 3158 0x2a, 0x00, 0x00, 0x00, // Stream 42 |
| 3153 0x00, 0x39, 0x00, 0x03, // Promised stream 57 | 3159 0x00, 0x39, 0x00, 0x03, // Promised stream 57 |
| 3154 0x78, 0x78, 0x78, 0x7f, // xxx. | 3160 0x78, 0x78, 0x78, 0x7f, // xxx. |
| 3155 0x80, 0x07, 0x78, 0x78, // ..xx | 3161 0x81, 0x07, 0x78, 0x78, // ..xx |
| 3156 0x78, 0x78, 0x78, 0x78, // xxxx | 3162 0x78, 0x78, 0x78, 0x78, // xxxx |
| 3157 0x78, 0x78, 0x78, 0x78, // xxxx | 3163 0x78, 0x78, 0x78, 0x78, // xxxx |
| 3158 0x78, 0x78, 0x78, 0x78, // xxxx | 3164 0x78, 0x78, 0x78, 0x78, // xxxx |
| 3159 0x78, 0x78, 0x78, 0x78, // xxxx | 3165 0x78, 0x78, 0x78, 0x78, // xxxx |
| 3160 0x78, 0x78, 0x78, 0x78, // xxxx | 3166 0x78, 0x78, 0x78, 0x78, // xxxx |
| 3161 0x78, 0x78, 0x78, 0x78, // xxxx | 3167 0x78, 0x78, 0x78, 0x78, // xxxx |
| 3162 0x78, 0x78, 0x78, 0x78, // xxxx | 3168 0x78, 0x78, 0x78, 0x78, // xxxx |
| 3163 0x78, 0x78, 0x78, 0x78, // xxxx | 3169 0x78, 0x78, 0x78, 0x78, // xxxx |
| 3164 0x78, 0x78, 0x78, 0x78, // xxxx | 3170 0x78, 0x78, 0x78, 0x78, // xxxx |
| 3165 0x78, 0x78, 0x78, 0x78, // xxxx | 3171 0x78, 0x78, 0x78, 0x78, // xxxx |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3182 0x2a, 0x78, 0x78, 0x78, // Stream 42, xxx | 3188 0x2a, 0x78, 0x78, 0x78, // Stream 42, xxx |
| 3183 0x78, 0x78, 0x78, 0x78, // xxxx | 3189 0x78, 0x78, 0x78, 0x78, // xxxx |
| 3184 0x78, 0x78, 0x78, 0x78, // xxxx | 3190 0x78, 0x78, 0x78, 0x78, // xxxx |
| 3185 0x78, 0x78, 0x78, 0x78, // xxxx | 3191 0x78, 0x78, 0x78, 0x78, // xxxx |
| 3186 0x78, 0x78, 0x78, 0x78, // xxxx | 3192 0x78, 0x78, 0x78, 0x78, // xxxx |
| 3187 0x78, 0x78, | 3193 0x78, 0x78, |
| 3188 }; | 3194 }; |
| 3189 | 3195 |
| 3190 SpdyPushPromiseIR push_promise(42, 57); | 3196 SpdyPushPromiseIR push_promise(42, 57); |
| 3191 push_promise.set_padding_len(1); | 3197 push_promise.set_padding_len(1); |
| 3192 string big_value(framer.GetHeaderFragmentMaxSize(), 'x'); | 3198 string big_value(TestSpdyVisitor::sent_control_frame_max_size(), 'x'); |
| 3193 push_promise.SetHeader("xxx", big_value); | 3199 push_promise.SetHeader("xxx", big_value); |
| 3194 scoped_ptr<SpdySerializedFrame> frame( | 3200 scoped_ptr<SpdySerializedFrame> frame( |
| 3195 framer.SerializePushPromise(push_promise)); | 3201 framer.SerializePushPromise(push_promise)); |
| 3196 | 3202 |
| 3197 // The entire frame should look like below: | 3203 // The entire frame should look like below: |
| 3198 // Name Length in Byte | 3204 // Name Length in Byte |
| 3199 // ------------------------------------------- Begin of PUSH_PROMISE frame | 3205 // ------------------------------------------- Begin of PUSH_PROMISE frame |
| 3200 // PUSH_PROMISE header 9 | 3206 // PUSH_PROMISE header 9 |
| 3201 // Pad length field 1 | 3207 // Pad length field 1 |
| 3202 // Promised stream 4 | 3208 // Promised stream 4 |
| 3203 // Length field of key 2 | 3209 // Length field of key 2 |
| 3204 // Content of key 3 | 3210 // Content of key 3 |
| 3205 // Length field of value 3 | 3211 // Length field of value 3 |
| 3206 // Part of big_value 16361 | 3212 // Part of big_value 16361 |
| 3207 // ------------------------------------------- Begin of CONTINUATION frame | 3213 // ------------------------------------------- Begin of CONTINUATION frame |
| 3208 // CONTINUATION header 9 | 3214 // CONTINUATION header 9 |
| 3209 // Remaining of big_value 22 | 3215 // Remaining of big_value 22 |
| 3210 // ------------------------------------------- End | 3216 // ------------------------------------------- End |
| 3211 | 3217 |
| 3212 // Length of everything listed above except big_value. | 3218 // Length of everything listed above except big_value. |
| 3213 int len_non_data_payload = 31; | 3219 int len_non_data_payload = 31; |
| 3214 EXPECT_EQ(framer.GetHeaderFragmentMaxSize() + len_non_data_payload, | 3220 EXPECT_EQ( |
| 3215 frame->size()); | 3221 TestSpdyVisitor::sent_control_frame_max_size() + len_non_data_payload, |
| 3222 frame->size()); |
| 3216 | 3223 |
| 3217 // Partially compare the PUSH_PROMISE frame against the template. | 3224 // Partially compare the PUSH_PROMISE frame against the template. |
| 3218 const unsigned char* frame_data = | 3225 const unsigned char* frame_data = |
| 3219 reinterpret_cast<const unsigned char*>(frame->data()); | 3226 reinterpret_cast<const unsigned char*>(frame->data()); |
| 3220 CompareCharArraysWithHexError(kDescription, | 3227 CompareCharArraysWithHexError(kDescription, |
| 3221 frame_data, | 3228 frame_data, |
| 3222 arraysize(kPartialPushPromiseFrameData), | 3229 arraysize(kPartialPushPromiseFrameData), |
| 3223 kPartialPushPromiseFrameData, | 3230 kPartialPushPromiseFrameData, |
| 3224 arraysize(kPartialPushPromiseFrameData)); | 3231 arraysize(kPartialPushPromiseFrameData)); |
| 3225 | 3232 |
| 3226 // Compare the CONTINUATION frame against the template. | 3233 // Compare the CONTINUATION frame against the template. |
| 3227 frame_data += framer.GetHeaderFragmentMaxSize(); | 3234 frame_data += TestSpdyVisitor::sent_control_frame_max_size(); |
| 3228 CompareCharArraysWithHexError(kDescription, | 3235 CompareCharArraysWithHexError(kDescription, |
| 3229 frame_data, | 3236 frame_data, |
| 3230 arraysize(kContinuationFrameData), | 3237 arraysize(kContinuationFrameData), |
| 3231 kContinuationFrameData, | 3238 kContinuationFrameData, |
| 3232 arraysize(kContinuationFrameData)); | 3239 arraysize(kContinuationFrameData)); |
| 3233 } | 3240 } |
| 3234 } | 3241 } |
| 3235 | 3242 |
| 3236 TEST_P(SpdyFramerTest, CreateAltSvc) { | 3243 TEST_P(SpdyFramerTest, CreateAltSvc) { |
| 3237 if (spdy_version_ <= SPDY3) { | 3244 if (spdy_version_ <= SPDY3) { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3388 } | 3395 } |
| 3389 // First find the size of the header value in order to just reach the control | 3396 // First find the size of the header value in order to just reach the control |
| 3390 // frame max size. | 3397 // frame max size. |
| 3391 SpdyFramer framer(spdy_version_); | 3398 SpdyFramer framer(spdy_version_); |
| 3392 framer.set_enable_compression(false); | 3399 framer.set_enable_compression(false); |
| 3393 SpdySynStreamIR syn_stream(1); | 3400 SpdySynStreamIR syn_stream(1); |
| 3394 syn_stream.set_priority(1); | 3401 syn_stream.set_priority(1); |
| 3395 syn_stream.SetHeader("aa", ""); | 3402 syn_stream.SetHeader("aa", ""); |
| 3396 scoped_ptr<SpdyFrame> control_frame(framer.SerializeSynStream(syn_stream)); | 3403 scoped_ptr<SpdyFrame> control_frame(framer.SerializeSynStream(syn_stream)); |
| 3397 const size_t kBigValueSize = | 3404 const size_t kBigValueSize = |
| 3398 framer.GetControlFrameBufferMaxSize() - control_frame->size(); | 3405 TestSpdyVisitor::sent_control_frame_max_size() - control_frame->size(); |
| 3399 | 3406 |
| 3400 // Create a frame at exactly that size. | 3407 // Create a frame at exactly that size. |
| 3401 string big_value(kBigValueSize, 'x'); | 3408 string big_value(kBigValueSize, 'x'); |
| 3402 syn_stream.SetHeader("aa", big_value); | 3409 syn_stream.SetHeader("aa", big_value); |
| 3403 control_frame.reset(framer.SerializeSynStream(syn_stream)); | 3410 control_frame.reset(framer.SerializeSynStream(syn_stream)); |
| 3404 EXPECT_TRUE(control_frame.get() != NULL); | 3411 EXPECT_TRUE(control_frame.get() != NULL); |
| 3405 EXPECT_EQ(framer.GetControlFrameBufferMaxSize(), control_frame->size()); | 3412 EXPECT_EQ(TestSpdyVisitor::sent_control_frame_max_size(), |
| 3413 control_frame->size()); |
| 3406 | 3414 |
| 3407 TestSpdyVisitor visitor(spdy_version_); | 3415 TestSpdyVisitor visitor(spdy_version_); |
| 3408 visitor.SimulateInFramer( | 3416 visitor.SimulateInFramer( |
| 3409 reinterpret_cast<unsigned char*>(control_frame->data()), | 3417 reinterpret_cast<unsigned char*>(control_frame->data()), |
| 3410 control_frame->size()); | 3418 control_frame->size()); |
| 3411 EXPECT_TRUE(visitor.header_buffer_valid_); | 3419 EXPECT_TRUE(visitor.header_buffer_valid_); |
| 3412 EXPECT_EQ(0, visitor.error_count_); | 3420 EXPECT_EQ(0, visitor.error_count_); |
| 3413 EXPECT_EQ(1, visitor.syn_frame_count_); | 3421 EXPECT_EQ(1, visitor.syn_frame_count_); |
| 3414 EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); | 3422 EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); |
| 3415 EXPECT_EQ(0, visitor.zero_length_data_frame_count_); | 3423 EXPECT_EQ(0, visitor.zero_length_data_frame_count_); |
| 3416 EXPECT_LT(kBigValueSize, visitor.header_buffer_length_); | 3424 EXPECT_LT(kBigValueSize, visitor.header_buffer_length_); |
| 3417 } | 3425 } |
| 3418 | 3426 |
| 3419 TEST_P(SpdyFramerTest, ControlFrameTooLarge) { | 3427 // This test is disabled because Chromium is willing to accept control frames up |
| 3428 // to the maximum size allowed by the specification, and SpdyFrameBuilder is not |
| 3429 // capable of building larger frames. |
| 3430 TEST_P(SpdyFramerTest, DISABLED_ControlFrameTooLarge) { |
| 3420 if (spdy_version_ > SPDY3) { | 3431 if (spdy_version_ > SPDY3) { |
| 3421 // TODO(jgraettinger): This test setup doesn't work with HPACK. | 3432 // TODO(jgraettinger): This test setup doesn't work with HPACK. |
| 3422 return; | 3433 return; |
| 3423 } | 3434 } |
| 3424 // First find the size of the header value in order to just reach the control | 3435 // First find the size of the header value in order to just reach the control |
| 3425 // frame max size. | 3436 // frame max size. |
| 3426 SpdyFramer framer(spdy_version_); | 3437 SpdyFramer framer(spdy_version_); |
| 3427 framer.set_enable_compression(false); | 3438 framer.set_enable_compression(false); |
| 3428 SpdySynStreamIR syn_stream(1); | 3439 SpdySynStreamIR syn_stream(1); |
| 3429 syn_stream.SetHeader("aa", ""); | 3440 syn_stream.SetHeader("aa", ""); |
| 3430 syn_stream.set_priority(1); | 3441 syn_stream.set_priority(1); |
| 3431 scoped_ptr<SpdyFrame> control_frame(framer.SerializeSynStream(syn_stream)); | 3442 scoped_ptr<SpdyFrame> control_frame(framer.SerializeSynStream(syn_stream)); |
| 3432 const size_t kBigValueSize = | 3443 const size_t kBigValueSize = |
| 3433 framer.GetControlFrameBufferMaxSize() - control_frame->size() + 1; | 3444 SpdyConstants::GetFrameMaximumSize(spdy_version_) - |
| 3445 control_frame->size() + 1; |
| 3434 | 3446 |
| 3435 // Create a frame at exatly that size. | 3447 // Create a frame at exatly that size. |
| 3436 string big_value(kBigValueSize, 'x'); | 3448 string big_value(kBigValueSize, 'x'); |
| 3437 syn_stream.SetHeader("aa", big_value); | 3449 syn_stream.SetHeader("aa", big_value); |
| 3438 // Upstream branches here and wraps SPDY4 with EXPECT_DEBUG_DFATAL. We | 3450 // Upstream branches here and wraps SPDY4 with EXPECT_DEBUG_DFATAL. We |
| 3439 // neither support that in Chromium, nor do we use the same DFATAL (see | 3451 // neither support that in Chromium, nor do we use the same DFATAL (see |
| 3440 // SpdyFrameBuilder::WriteFramePrefix()). | 3452 // SpdyFrameBuilder::WriteFramePrefix()). |
| 3441 control_frame.reset(framer.SerializeSynStream(syn_stream)); | 3453 control_frame.reset(framer.SerializeSynStream(syn_stream)); |
| 3442 | 3454 |
| 3443 EXPECT_TRUE(control_frame.get() != NULL); | 3455 EXPECT_TRUE(control_frame.get() != NULL); |
| 3444 EXPECT_EQ(framer.GetControlFrameBufferMaxSize() + 1, | 3456 EXPECT_EQ(SpdyConstants::GetFrameMaximumSize(spdy_version_) + 1, |
| 3445 control_frame->size()); | 3457 control_frame->size()); |
| 3446 | 3458 |
| 3447 TestSpdyVisitor visitor(spdy_version_); | 3459 TestSpdyVisitor visitor(spdy_version_); |
| 3448 visitor.SimulateInFramer( | 3460 visitor.SimulateInFramer( |
| 3449 reinterpret_cast<unsigned char*>(control_frame->data()), | 3461 reinterpret_cast<unsigned char*>(control_frame->data()), |
| 3450 control_frame->size()); | 3462 control_frame->size()); |
| 3451 EXPECT_FALSE(visitor.header_buffer_valid_); | 3463 EXPECT_FALSE(visitor.header_buffer_valid_); |
| 3452 EXPECT_EQ(1, visitor.error_count_); | 3464 EXPECT_EQ(1, visitor.error_count_); |
| 3453 EXPECT_EQ(SpdyFramer::SPDY_CONTROL_PAYLOAD_TOO_LARGE, | 3465 EXPECT_EQ(SpdyFramer::SPDY_CONTROL_PAYLOAD_TOO_LARGE, |
| 3454 visitor.framer_.error_code()) | 3466 visitor.framer_.error_code()) |
| 3455 << SpdyFramer::ErrorCodeToString(framer.error_code()); | 3467 << SpdyFramer::ErrorCodeToString(framer.error_code()); |
| 3456 EXPECT_EQ(0, visitor.syn_frame_count_); | 3468 EXPECT_EQ(0, visitor.syn_frame_count_); |
| 3457 EXPECT_EQ(0u, visitor.header_buffer_length_); | 3469 EXPECT_EQ(0u, visitor.header_buffer_length_); |
| 3458 } | 3470 } |
| 3459 | 3471 |
| 3460 TEST_P(SpdyFramerTest, TooLargeHeadersFrameUsesContinuation) { | 3472 TEST_P(SpdyFramerTest, TooLargeHeadersFrameUsesContinuation) { |
| 3461 if (spdy_version_ <= SPDY3) { | 3473 if (spdy_version_ <= SPDY3) { |
| 3462 return; | 3474 return; |
| 3463 } | 3475 } |
| 3464 SpdyFramer framer(spdy_version_); | 3476 SpdyFramer framer(spdy_version_); |
| 3465 framer.set_enable_compression(false); | 3477 framer.set_enable_compression(false); |
| 3466 SpdyHeadersIR headers(1); | 3478 SpdyHeadersIR headers(1); |
| 3467 headers.set_padding_len(256); | 3479 headers.set_padding_len(256); |
| 3468 | 3480 |
| 3469 // Exact payload length will change with HPACK, but this should be long | 3481 // Exact payload length will change with HPACK, but this should be long |
| 3470 // enough to cause an overflow. | 3482 // enough to cause an overflow. |
| 3471 const size_t kBigValueSize = framer.GetControlFrameBufferMaxSize(); | 3483 const size_t kBigValueSize = kControlFrameSizeLimit; |
| 3472 string big_value(kBigValueSize, 'x'); | 3484 string big_value(kBigValueSize, 'x'); |
| 3473 headers.SetHeader("aa", big_value); | 3485 headers.SetHeader("aa", big_value); |
| 3474 scoped_ptr<SpdyFrame> control_frame(framer.SerializeHeaders(headers)); | 3486 scoped_ptr<SpdyFrame> control_frame(framer.SerializeHeaders(headers)); |
| 3475 EXPECT_TRUE(control_frame.get() != NULL); | 3487 EXPECT_TRUE(control_frame.get() != NULL); |
| 3476 EXPECT_GT(control_frame->size(), framer.GetControlFrameBufferMaxSize()); | 3488 EXPECT_GT(control_frame->size(), |
| 3489 TestSpdyVisitor::sent_control_frame_max_size()); |
| 3477 | 3490 |
| 3478 TestSpdyVisitor visitor(spdy_version_); | 3491 TestSpdyVisitor visitor(spdy_version_); |
| 3479 visitor.SimulateInFramer( | 3492 visitor.SimulateInFramer( |
| 3480 reinterpret_cast<unsigned char*>(control_frame->data()), | 3493 reinterpret_cast<unsigned char*>(control_frame->data()), |
| 3481 control_frame->size()); | 3494 control_frame->size()); |
| 3482 EXPECT_TRUE(visitor.header_buffer_valid_); | 3495 EXPECT_TRUE(visitor.header_buffer_valid_); |
| 3483 EXPECT_EQ(0, visitor.error_count_); | 3496 EXPECT_EQ(0, visitor.error_count_); |
| 3484 EXPECT_EQ(1, visitor.headers_frame_count_); | 3497 EXPECT_EQ(1, visitor.headers_frame_count_); |
| 3485 EXPECT_EQ(16, visitor.continuation_count_); | 3498 EXPECT_EQ(16, visitor.continuation_count_); |
| 3486 EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); | 3499 EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); |
| 3487 } | 3500 } |
| 3488 | 3501 |
| 3489 TEST_P(SpdyFramerTest, TooLargePushPromiseFrameUsesContinuation) { | 3502 TEST_P(SpdyFramerTest, TooLargePushPromiseFrameUsesContinuation) { |
| 3490 if (spdy_version_ <= SPDY3) { | 3503 if (spdy_version_ <= SPDY3) { |
| 3491 return; | 3504 return; |
| 3492 } | 3505 } |
| 3493 SpdyFramer framer(spdy_version_); | 3506 SpdyFramer framer(spdy_version_); |
| 3494 framer.set_enable_compression(false); | 3507 framer.set_enable_compression(false); |
| 3495 SpdyPushPromiseIR push_promise(1, 2); | 3508 SpdyPushPromiseIR push_promise(1, 2); |
| 3496 push_promise.set_padding_len(256); | 3509 push_promise.set_padding_len(256); |
| 3497 | 3510 |
| 3498 // Exact payload length will change with HPACK, but this should be long | 3511 // Exact payload length will change with HPACK, but this should be long |
| 3499 // enough to cause an overflow. | 3512 // enough to cause an overflow. |
| 3500 const size_t kBigValueSize = framer.GetControlFrameBufferMaxSize(); | 3513 const size_t kBigValueSize = kControlFrameSizeLimit; |
| 3501 string big_value(kBigValueSize, 'x'); | 3514 string big_value(kBigValueSize, 'x'); |
| 3502 push_promise.SetHeader("aa", big_value); | 3515 push_promise.SetHeader("aa", big_value); |
| 3503 scoped_ptr<SpdyFrame> control_frame( | 3516 scoped_ptr<SpdyFrame> control_frame( |
| 3504 framer.SerializePushPromise(push_promise)); | 3517 framer.SerializePushPromise(push_promise)); |
| 3505 EXPECT_TRUE(control_frame.get() != NULL); | 3518 EXPECT_TRUE(control_frame.get() != NULL); |
| 3506 EXPECT_GT(control_frame->size(), framer.GetControlFrameBufferMaxSize()); | 3519 EXPECT_GT(control_frame->size(), |
| 3520 TestSpdyVisitor::sent_control_frame_max_size()); |
| 3507 | 3521 |
| 3508 TestSpdyVisitor visitor(spdy_version_); | 3522 TestSpdyVisitor visitor(spdy_version_); |
| 3509 visitor.SimulateInFramer( | 3523 visitor.SimulateInFramer( |
| 3510 reinterpret_cast<unsigned char*>(control_frame->data()), | 3524 reinterpret_cast<unsigned char*>(control_frame->data()), |
| 3511 control_frame->size()); | 3525 control_frame->size()); |
| 3512 EXPECT_TRUE(visitor.header_buffer_valid_); | 3526 EXPECT_TRUE(visitor.header_buffer_valid_); |
| 3513 EXPECT_EQ(0, visitor.error_count_); | 3527 EXPECT_EQ(0, visitor.error_count_); |
| 3514 EXPECT_EQ(1, visitor.push_promise_frame_count_); | 3528 EXPECT_EQ(1, visitor.push_promise_frame_count_); |
| 3515 EXPECT_EQ(16, visitor.continuation_count_); | 3529 EXPECT_EQ(16, visitor.continuation_count_); |
| 3516 EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); | 3530 EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); |
| (...skipping 2225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5742 TestSpdyVisitor visitor(spdy_version_); | 5756 TestSpdyVisitor visitor(spdy_version_); |
| 5743 visitor.SimulateInFramer(kFrameData, sizeof(kFrameData)); | 5757 visitor.SimulateInFramer(kFrameData, sizeof(kFrameData)); |
| 5744 | 5758 |
| 5745 EXPECT_EQ(SpdyFramer::SPDY_ERROR, visitor.framer_.state()); | 5759 EXPECT_EQ(SpdyFramer::SPDY_ERROR, visitor.framer_.state()); |
| 5746 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, | 5760 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, |
| 5747 visitor.framer_.error_code()) | 5761 visitor.framer_.error_code()) |
| 5748 << SpdyFramer::ErrorCodeToString(visitor.framer_.error_code()); | 5762 << SpdyFramer::ErrorCodeToString(visitor.framer_.error_code()); |
| 5749 } | 5763 } |
| 5750 | 5764 |
| 5751 } // namespace net | 5765 } // namespace net |
| OLD | NEW |