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 3265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3276 TEST_P(SpdyFramerTest, CreateContinuationUncompressed) { | 3276 TEST_P(SpdyFramerTest, CreateContinuationUncompressed) { |
3277 if (spdy_version_ <= SPDY3) { | 3277 if (spdy_version_ <= SPDY3) { |
3278 return; | 3278 return; |
3279 } | 3279 } |
3280 | 3280 |
3281 SpdyFramer framer(spdy_version_); | 3281 SpdyFramer framer(spdy_version_); |
3282 framer.set_enable_compression(false); | 3282 framer.set_enable_compression(false); |
3283 const char kDescription[] = "CONTINUATION frame"; | 3283 const char kDescription[] = "CONTINUATION frame"; |
3284 | 3284 |
3285 const unsigned char kFrameData[] = { | 3285 const unsigned char kFrameData[] = { |
3286 0x00, 0x00, 0x12, 0x09, 0x00, // CONTINUATION | 3286 0x00, 0x00, 0x12, 0x09, // CONTINUATION |
3287 0x00, 0x00, 0x00, 0x2a, // Stream 42 | 3287 0x04, 0x00, 0x00, 0x00, // end_headers = true |
3288 0x00, 0x03, 0x62, 0x61, // @.ba | 3288 0x2a, 0x00, 0x03, 0x62, // Stream 42, @.b |
3289 0x72, 0x03, 0x66, 0x6f, // r.fo | 3289 0x61, 0x72, 0x03, 0x66, // ar.f |
3290 0x6f, 0x00, 0x03, 0x66, // o@.f | 3290 0x6f, 0x6f, 0x00, 0x03, // oo@. |
3291 0x6f, 0x6f, 0x03, 0x62, // oo.b | 3291 0x66, 0x6f, 0x6f, 0x03, // foo. |
3292 0x61, 0x72, // ar | 3292 0x62, 0x61, 0x72, // bar |
3293 }; | 3293 }; |
3294 | 3294 |
3295 SpdyContinuationIR continuation(42); | 3295 SpdyContinuationIR continuation(42); |
3296 continuation.SetHeader("bar", "foo"); | 3296 continuation.SetHeader("bar", "foo"); |
3297 continuation.SetHeader("foo", "bar"); | 3297 continuation.SetHeader("foo", "bar"); |
| 3298 continuation.set_end_headers(true); |
3298 scoped_ptr<SpdySerializedFrame> frame( | 3299 scoped_ptr<SpdySerializedFrame> frame( |
3299 framer.SerializeContinuation(continuation)); | 3300 framer.SerializeContinuation(continuation)); |
3300 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData)); | 3301 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData)); |
3301 } | 3302 } |
3302 | 3303 |
3303 TEST_P(SpdyFramerTest, CreatePushPromiseThenContinuationUncompressed) { | 3304 TEST_P(SpdyFramerTest, CreatePushPromiseThenContinuationUncompressed) { |
3304 if (spdy_version_ <= SPDY3) { | 3305 if (spdy_version_ <= SPDY3) { |
3305 return; | 3306 return; |
3306 } | 3307 } |
3307 | 3308 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3444 SpdyConstants::SerializeFrameType(spdy_version_, PRIORITY)); | 3445 SpdyConstants::SerializeFrameType(spdy_version_, PRIORITY)); |
3445 const unsigned char kFrameData[] = { | 3446 const unsigned char kFrameData[] = { |
3446 0x00, 0x00, 0x05, kType, 0x00, | 3447 0x00, 0x00, 0x05, kType, 0x00, |
3447 0x00, 0x00, 0x00, 0x02, // Stream ID = 2 | 3448 0x00, 0x00, 0x00, 0x02, // Stream ID = 2 |
3448 0x80, 0x00, 0x00, 0x01, // Exclusive dependency, parent stream ID = 1 | 3449 0x80, 0x00, 0x00, 0x01, // Exclusive dependency, parent stream ID = 1 |
3449 0x10, // Weight = 16 | 3450 0x10, // Weight = 16 |
3450 }; | 3451 }; |
3451 SpdyPriorityIR priority_ir(2, 1, 16, true); | 3452 SpdyPriorityIR priority_ir(2, 1, 16, true); |
3452 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(priority_ir)); | 3453 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(priority_ir)); |
3453 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData)); | 3454 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData)); |
| 3455 SpdyPriorityIR priority2(2); |
| 3456 priority2.set_parent_stream_id(1); |
| 3457 priority2.set_weight(16); |
| 3458 priority2.set_exclusive(true); |
| 3459 frame.reset(framer.SerializeFrame(priority2)); |
| 3460 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData)); |
3454 } | 3461 } |
3455 | 3462 |
3456 TEST_P(SpdyFramerTest, ReadCompressedSynStreamHeaderBlock) { | 3463 TEST_P(SpdyFramerTest, ReadCompressedSynStreamHeaderBlock) { |
3457 if (spdy_version_ > SPDY3) { | 3464 if (spdy_version_ > SPDY3) { |
3458 // SYN_STREAM not supported in SPDY>3 | 3465 // SYN_STREAM not supported in SPDY>3 |
3459 return; | 3466 return; |
3460 } | 3467 } |
3461 SpdyFramer framer(spdy_version_); | 3468 SpdyFramer framer(spdy_version_); |
3462 SpdySynStreamIR syn_stream(1); | 3469 SpdySynStreamIR syn_stream(1); |
3463 syn_stream.set_priority(1); | 3470 syn_stream.set_priority(1); |
(...skipping 2471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5935 TestSpdyVisitor visitor(spdy_version_); | 5942 TestSpdyVisitor visitor(spdy_version_); |
5936 visitor.SimulateInFramer(kFrameData, sizeof(kFrameData)); | 5943 visitor.SimulateInFramer(kFrameData, sizeof(kFrameData)); |
5937 | 5944 |
5938 EXPECT_EQ(SpdyFramer::SPDY_ERROR, visitor.framer_.state()); | 5945 EXPECT_EQ(SpdyFramer::SPDY_ERROR, visitor.framer_.state()); |
5939 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, | 5946 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, |
5940 visitor.framer_.error_code()) | 5947 visitor.framer_.error_code()) |
5941 << SpdyFramer::ErrorCodeToString(visitor.framer_.error_code()); | 5948 << SpdyFramer::ErrorCodeToString(visitor.framer_.error_code()); |
5942 } | 5949 } |
5943 | 5950 |
5944 } // namespace net | 5951 } // namespace net |
OLD | NEW |