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 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 serialized_headers.size() - 2, | 685 serialized_headers.size() - 2, |
686 &new_headers)); | 686 &new_headers)); |
687 } | 687 } |
688 | 688 |
689 TEST_P(SpdyFramerTest, OutOfOrderHeaders) { | 689 TEST_P(SpdyFramerTest, OutOfOrderHeaders) { |
690 SpdyFramer framer(spdy_version_); | 690 SpdyFramer framer(spdy_version_); |
691 framer.set_enable_compression(false); | 691 framer.set_enable_compression(false); |
692 | 692 |
693 // Frame builder with plentiful buffer size. | 693 // Frame builder with plentiful buffer size. |
694 SpdyFrameBuilder frame(1024); | 694 SpdyFrameBuilder frame(1024); |
695 frame.WriteControlFrameHeader(framer, SYN_STREAM, CONTROL_FLAG_NONE); | 695 if (spdy_version_ < 4) { |
| 696 frame.WriteControlFrameHeader(framer, SYN_STREAM, CONTROL_FLAG_NONE); |
| 697 frame.WriteUInt32(3); // stream_id |
| 698 } else { |
| 699 frame.WriteFramePrefix(framer, SYN_STREAM, CONTROL_FLAG_NONE, 3); |
| 700 } |
696 | 701 |
697 frame.WriteUInt32(3); // stream_id | |
698 frame.WriteUInt32(0); // Associated stream id | 702 frame.WriteUInt32(0); // Associated stream id |
699 frame.WriteUInt16(0); // Priority. | 703 frame.WriteUInt16(0); // Priority. |
700 | 704 |
701 if (IsSpdy2()) { | 705 if (IsSpdy2()) { |
702 frame.WriteUInt16(2); // Number of headers. | 706 frame.WriteUInt16(2); // Number of headers. |
703 frame.WriteString("gamma"); | 707 frame.WriteString("gamma"); |
704 frame.WriteString("gamma"); | 708 frame.WriteString("gamma"); |
705 frame.WriteString("alpha"); | 709 frame.WriteString("alpha"); |
706 frame.WriteString("alpha"); | 710 frame.WriteString("alpha"); |
707 } else { | 711 } else { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 't', 0x00, 0x00, 0x00, | 743 't', 0x00, 0x00, 0x00, |
740 0x0C, 'a', 'n', 'o', | 744 0x0C, 'a', 'n', 'o', |
741 't', 'h', 'e', 'r', | 745 't', 'h', 'e', 'r', |
742 ' ', 'c', 'e', 'r', | 746 ' ', 'c', 'e', 'r', |
743 't', 0x00, 0x00, 0x00, | 747 't', 0x00, 0x00, 0x00, |
744 0x0A, 'f', 'i', 'n', | 748 0x0A, 'f', 'i', 'n', |
745 'a', 'l', ' ', 'c', | 749 'a', 'l', ' ', 'c', |
746 'e', 'r', 't', | 750 'e', 'r', 't', |
747 }; | 751 }; |
748 const unsigned char kV4FrameData[] = { | 752 const unsigned char kV4FrameData[] = { |
749 0x00, 0x37, 0x0A, 0x00, | 753 0x00, 0x3b, 0x0A, 0x00, |
| 754 0x00, 0x00, 0x00, 0x00, |
750 0x00, 0x03, 0x00, 0x00, | 755 0x00, 0x03, 0x00, 0x00, |
751 0x00, 0x05, 'p', 'r', | 756 0x00, 0x05, 'p', 'r', |
752 'o', 'o', 'f', 0x00, | 757 'o', 'o', 'f', 0x00, |
753 0x00, 0x00, 0x06, 'a', | 758 0x00, 0x00, 0x06, 'a', |
754 ' ', 'c', 'e', 'r', | 759 ' ', 'c', 'e', 'r', |
755 't', 0x00, 0x00, 0x00, | 760 't', 0x00, 0x00, 0x00, |
756 0x0C, 'a', 'n', 'o', | 761 0x0C, 'a', 'n', 'o', |
757 't', 'h', 'e', 'r', | 762 't', 'h', 'e', 'r', |
758 ' ', 'c', 'e', 'r', | 763 ' ', 'c', 'e', 'r', |
759 't', 0x00, 0x00, 0x00, | 764 't', 0x00, 0x00, 0x00, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 0x0C, 'a', 'n', 'o', | 797 0x0C, 'a', 'n', 'o', |
793 't', 'h', 'e', 'r', | 798 't', 'h', 'e', 'r', |
794 ' ', 'c', 'e', 'r', | 799 ' ', 'c', 'e', 'r', |
795 't', 0x00, 0x00, 0x00, | 800 't', 0x00, 0x00, 0x00, |
796 0x0A, 'f', 'i', 'n', | 801 0x0A, 'f', 'i', 'n', |
797 'a', 'l', ' ', 'c', | 802 'a', 'l', ' ', 'c', |
798 'e', 'r', 't', | 803 'e', 'r', 't', |
799 }; | 804 }; |
800 const unsigned char kV4FrameData[] = { | 805 const unsigned char kV4FrameData[] = { |
801 0x00, 0x37, 0x0A, 0x00, | 806 0x00, 0x37, 0x0A, 0x00, |
| 807 0x00, 0x00, 0x00, 0x00, |
802 0x00, 0x03, 0x00, 0x00, | 808 0x00, 0x03, 0x00, 0x00, |
803 0x00, 0x05, 'p', 'r', | 809 0x00, 0x05, 'p', 'r', |
804 'o', 'o', 'f', 0x00, | 810 'o', 'o', 'f', 0x00, |
805 0x00, 0x00, 0x06, 'a', | 811 0x00, 0x00, 0x06, 'a', |
806 ' ', 'c', 'e', 'r', | 812 ' ', 'c', 'e', 'r', |
807 't', 0x00, 0x00, 0x00, | 813 't', 0x00, 0x00, 0x00, |
808 0x0C, 'a', 'n', 'o', | 814 0x0C, 'a', 'n', 'o', |
809 't', 'h', 'e', 'r', | 815 't', 'h', 'e', 'r', |
810 ' ', 'c', 'e', 'r', | 816 ' ', 'c', 'e', 'r', |
811 't', 0x00, 0x00, 0x00, | 817 't', 0x00, 0x00, 0x00, |
(...skipping 25 matching lines...) Expand all Loading... |
837 EXPECT_EQ("final cert", credential.certs.front()); | 843 EXPECT_EQ("final cert", credential.certs.front()); |
838 credential.certs.erase(credential.certs.begin()); | 844 credential.certs.erase(credential.certs.begin()); |
839 EXPECT_TRUE(credential.certs.empty()); | 845 EXPECT_TRUE(credential.certs.empty()); |
840 } | 846 } |
841 } | 847 } |
842 | 848 |
843 TEST_P(SpdyFramerTest, DuplicateHeader) { | 849 TEST_P(SpdyFramerTest, DuplicateHeader) { |
844 SpdyFramer framer(spdy_version_); | 850 SpdyFramer framer(spdy_version_); |
845 // Frame builder with plentiful buffer size. | 851 // Frame builder with plentiful buffer size. |
846 SpdyFrameBuilder frame(1024); | 852 SpdyFrameBuilder frame(1024); |
847 frame.WriteControlFrameHeader(framer, SYN_STREAM, CONTROL_FLAG_NONE); | 853 if (spdy_version_ < 4) { |
| 854 frame.WriteControlFrameHeader(framer, SYN_STREAM, CONTROL_FLAG_NONE); |
| 855 frame.WriteUInt32(3); // stream_id |
| 856 } else { |
| 857 frame.WriteFramePrefix(framer, SYN_STREAM, CONTROL_FLAG_NONE, 3); |
| 858 } |
848 | 859 |
849 frame.WriteUInt32(3); // stream_id | |
850 frame.WriteUInt32(0); // associated stream id | 860 frame.WriteUInt32(0); // associated stream id |
851 frame.WriteUInt16(0); // Priority. | 861 frame.WriteUInt16(0); // Priority. |
852 | 862 |
853 if (IsSpdy2()) { | 863 if (IsSpdy2()) { |
854 frame.WriteUInt16(2); // Number of headers. | 864 frame.WriteUInt16(2); // Number of headers. |
855 frame.WriteString("name"); | 865 frame.WriteString("name"); |
856 frame.WriteString("value1"); | 866 frame.WriteString("value1"); |
857 frame.WriteString("name"); | 867 frame.WriteString("name"); |
858 frame.WriteString("value2"); | 868 frame.WriteString("value2"); |
859 } else { | 869 } else { |
(...skipping 14 matching lines...) Expand all Loading... |
874 // This should fail because duplicate headers are verboten by the spec. | 884 // This should fail because duplicate headers are verboten by the spec. |
875 EXPECT_FALSE(framer.ParseHeaderBlockInBuffer(serialized_headers.data(), | 885 EXPECT_FALSE(framer.ParseHeaderBlockInBuffer(serialized_headers.data(), |
876 serialized_headers.size(), | 886 serialized_headers.size(), |
877 &new_headers)); | 887 &new_headers)); |
878 } | 888 } |
879 | 889 |
880 TEST_P(SpdyFramerTest, MultiValueHeader) { | 890 TEST_P(SpdyFramerTest, MultiValueHeader) { |
881 SpdyFramer framer(spdy_version_); | 891 SpdyFramer framer(spdy_version_); |
882 // Frame builder with plentiful buffer size. | 892 // Frame builder with plentiful buffer size. |
883 SpdyFrameBuilder frame(1024); | 893 SpdyFrameBuilder frame(1024); |
884 frame.WriteControlFrameHeader(framer, SYN_STREAM, CONTROL_FLAG_NONE); | 894 if (spdy_version_ < 4) { |
| 895 frame.WriteControlFrameHeader(framer, SYN_STREAM, CONTROL_FLAG_NONE); |
| 896 frame.WriteUInt32(3); // stream_id |
| 897 } else { |
| 898 frame.WriteFramePrefix(framer, SYN_STREAM, CONTROL_FLAG_NONE, 3); |
| 899 } |
885 | 900 |
886 frame.WriteUInt32(3); // stream_id | |
887 frame.WriteUInt32(0); // associated stream id | 901 frame.WriteUInt32(0); // associated stream id |
888 frame.WriteUInt16(0); // Priority. | 902 frame.WriteUInt16(0); // Priority. |
889 | 903 |
890 string value("value1\0value2"); | 904 string value("value1\0value2"); |
891 if (IsSpdy2()) { | 905 if (IsSpdy2()) { |
892 frame.WriteUInt16(1); // Number of headers. | 906 frame.WriteUInt16(1); // Number of headers. |
893 frame.WriteString("name"); | 907 frame.WriteString("name"); |
894 frame.WriteString(value); | 908 frame.WriteString(value); |
895 } else { | 909 } else { |
896 frame.WriteUInt32(1); // Number of headers. | 910 frame.WriteUInt32(1); // Number of headers. |
(...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2383 0x0a, 0x0b, 0x0c, 0x0d, | 2397 0x0a, 0x0b, 0x0c, 0x0d, |
2384 }; | 2398 }; |
2385 const unsigned char kV3FrameData[] = { | 2399 const unsigned char kV3FrameData[] = { |
2386 0x80, spdy_version_, 0x00, 0x04, | 2400 0x80, spdy_version_, 0x00, 0x04, |
2387 0x00, 0x00, 0x00, 0x0c, | 2401 0x00, 0x00, 0x00, 0x0c, |
2388 0x00, 0x00, 0x00, 0x01, | 2402 0x00, 0x00, 0x00, 0x01, |
2389 0x01, 0x02, 0x03, 0x04, | 2403 0x01, 0x02, 0x03, 0x04, |
2390 0x0a, 0x0b, 0x0c, 0x0d, | 2404 0x0a, 0x0b, 0x0c, 0x0d, |
2391 }; | 2405 }; |
2392 const unsigned char kV4FrameData[] = { | 2406 const unsigned char kV4FrameData[] = { |
2393 0x00, 0x10, 0x04, 0x00, | 2407 0x00, 0x14, 0x04, 0x00, |
| 2408 0x00, 0x00, 0x00, 0x00, |
2394 0x00, 0x00, 0x00, 0x01, | 2409 0x00, 0x00, 0x00, 0x01, |
2395 0x01, 0x02, 0x03, 0x04, | 2410 0x01, 0x02, 0x03, 0x04, |
2396 0x0a, 0x0b, 0x0c, 0x0d, | 2411 0x0a, 0x0b, 0x0c, 0x0d, |
2397 }; | 2412 }; |
2398 | 2413 |
2399 scoped_ptr<SpdyFrame> frame(framer.CreateSettings(settings)); | 2414 scoped_ptr<SpdyFrame> frame(framer.CreateSettings(settings)); |
2400 if (IsSpdy2()) { | 2415 if (IsSpdy2()) { |
2401 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); | 2416 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); |
2402 } else if (IsSpdy3()) { | 2417 } else if (IsSpdy3()) { |
2403 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2418 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
(...skipping 22 matching lines...) Expand all Loading... |
2426 0x00, 0x00, 0x00, 0x00, // 1st Setting | 2441 0x00, 0x00, 0x00, 0x00, // 1st Setting |
2427 0x00, 0x00, 0x00, 0x01, | 2442 0x00, 0x00, 0x00, 0x01, |
2428 0x01, 0x00, 0x00, 0x01, // 2nd Setting | 2443 0x01, 0x00, 0x00, 0x01, // 2nd Setting |
2429 0x00, 0x00, 0x00, 0x02, | 2444 0x00, 0x00, 0x00, 0x02, |
2430 0x02, 0x00, 0x00, 0x02, // 3rd Setting | 2445 0x02, 0x00, 0x00, 0x02, // 3rd Setting |
2431 0x00, 0x00, 0x00, 0x03, | 2446 0x00, 0x00, 0x00, 0x03, |
2432 0x03, 0x00, 0x00, 0x03, // 4th Setting | 2447 0x03, 0x00, 0x00, 0x03, // 4th Setting |
2433 0xff, 0x00, 0x00, 0x04, | 2448 0xff, 0x00, 0x00, 0x04, |
2434 }; | 2449 }; |
2435 const unsigned char kV4FrameData[] = { | 2450 const unsigned char kV4FrameData[] = { |
2436 0x00, 0x28, 0x04, 0x00, | 2451 0x00, 0x2c, 0x04, 0x00, |
| 2452 0x00, 0x00, 0x00, 0x00, |
2437 0x00, 0x00, 0x00, 0x04, | 2453 0x00, 0x00, 0x00, 0x04, |
2438 0x00, 0x00, 0x00, 0x00, // 1st Setting | 2454 0x00, 0x00, 0x00, 0x00, // 1st Setting |
2439 0x00, 0x00, 0x00, 0x01, | 2455 0x00, 0x00, 0x00, 0x01, |
2440 0x01, 0x00, 0x00, 0x01, // 2nd Setting | 2456 0x01, 0x00, 0x00, 0x01, // 2nd Setting |
2441 0x00, 0x00, 0x00, 0x02, | 2457 0x00, 0x00, 0x00, 0x02, |
2442 0x02, 0x00, 0x00, 0x02, // 3rd Setting | 2458 0x02, 0x00, 0x00, 0x02, // 3rd Setting |
2443 0x00, 0x00, 0x00, 0x03, | 2459 0x00, 0x00, 0x00, 0x03, |
2444 0x03, 0x00, 0x00, 0x03, // 4th Setting | 2460 0x03, 0x00, 0x00, 0x03, // 4th Setting |
2445 0xff, 0x00, 0x00, 0x04, | 2461 0xff, 0x00, 0x00, 0x04, |
2446 }; | 2462 }; |
2447 scoped_ptr<SpdyFrame> frame(framer.CreateSettings(settings)); | 2463 scoped_ptr<SpdyFrame> frame(framer.CreateSettings(settings)); |
2448 if (IsSpdy4()) { | 2464 if (IsSpdy4()) { |
2449 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2465 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
2450 } else { | 2466 } else { |
2451 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2467 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
2452 } | 2468 } |
2453 } | 2469 } |
2454 | 2470 |
2455 { | 2471 { |
2456 const char kDescription[] = "Empty SETTINGS frame"; | 2472 const char kDescription[] = "Empty SETTINGS frame"; |
2457 | 2473 |
2458 SettingsMap settings; | 2474 SettingsMap settings; |
2459 | 2475 |
2460 const unsigned char kV3FrameData[] = { // Also applies for V2. | 2476 const unsigned char kV3FrameData[] = { // Also applies for V2. |
2461 0x80, spdy_version_, 0x00, 0x04, | 2477 0x80, spdy_version_, 0x00, 0x04, |
2462 0x00, 0x00, 0x00, 0x04, | 2478 0x00, 0x00, 0x00, 0x04, |
2463 0x00, 0x00, 0x00, 0x00, | 2479 0x00, 0x00, 0x00, 0x00, |
2464 }; | 2480 }; |
2465 const unsigned char kV4FrameData[] = { | 2481 const unsigned char kV4FrameData[] = { |
2466 0x00, 0x08, 0x04, 0x00, | 2482 0x00, 0x0c, 0x04, 0x00, |
| 2483 0x00, 0x00, 0x00, 0x00, |
2467 0x00, 0x00, 0x00, 0x00, | 2484 0x00, 0x00, 0x00, 0x00, |
2468 }; | 2485 }; |
2469 scoped_ptr<SpdyFrame> frame(framer.CreateSettings(settings)); | 2486 scoped_ptr<SpdyFrame> frame(framer.CreateSettings(settings)); |
2470 if (IsSpdy4()) { | 2487 if (IsSpdy4()) { |
2471 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2488 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
2472 } else { | 2489 } else { |
2473 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2490 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
2474 } | 2491 } |
2475 } | 2492 } |
2476 } | 2493 } |
2477 | 2494 |
2478 TEST_P(SpdyFramerTest, CreatePingFrame) { | 2495 TEST_P(SpdyFramerTest, CreatePingFrame) { |
2479 SpdyFramer framer(spdy_version_); | 2496 SpdyFramer framer(spdy_version_); |
2480 | 2497 |
2481 { | 2498 { |
2482 const char kDescription[] = "PING frame"; | 2499 const char kDescription[] = "PING frame"; |
2483 const unsigned char kV3FrameData[] = { // Also applies for V2. | 2500 const unsigned char kV3FrameData[] = { // Also applies for V2. |
2484 0x80, spdy_version_, 0x00, 0x06, | 2501 0x80, spdy_version_, 0x00, 0x06, |
2485 0x00, 0x00, 0x00, 0x04, | 2502 0x00, 0x00, 0x00, 0x04, |
2486 0x12, 0x34, 0x56, 0x78, | 2503 0x12, 0x34, 0x56, 0x78, |
2487 }; | 2504 }; |
2488 const unsigned char kV4FrameData[] = { | 2505 const unsigned char kV4FrameData[] = { |
2489 0x00, 0x08, 0x06, 0x00, | 2506 0x00, 0x0c, 0x06, 0x00, |
| 2507 0x00, 0x00, 0x00, 0x00, |
2490 0x12, 0x34, 0x56, 0x78, | 2508 0x12, 0x34, 0x56, 0x78, |
2491 }; | 2509 }; |
2492 scoped_ptr<SpdyFrame> frame(framer.CreatePingFrame(0x12345678u)); | 2510 scoped_ptr<SpdyFrame> frame(framer.CreatePingFrame(0x12345678u)); |
2493 if (IsSpdy4()) { | 2511 if (IsSpdy4()) { |
2494 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2512 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
2495 } else { | 2513 } else { |
2496 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2514 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
2497 } | 2515 } |
2498 } | 2516 } |
2499 } | 2517 } |
2500 | 2518 |
2501 TEST_P(SpdyFramerTest, CreateGoAway) { | 2519 TEST_P(SpdyFramerTest, CreateGoAway) { |
2502 SpdyFramer framer(spdy_version_); | 2520 SpdyFramer framer(spdy_version_); |
2503 | 2521 |
2504 { | 2522 { |
2505 const char kDescription[] = "GOAWAY frame"; | 2523 const char kDescription[] = "GOAWAY frame"; |
2506 const unsigned char kV2FrameData[] = { | 2524 const unsigned char kV2FrameData[] = { |
2507 0x80, spdy_version_, 0x00, 0x07, | 2525 0x80, spdy_version_, 0x00, 0x07, |
2508 0x00, 0x00, 0x00, 0x04, | 2526 0x00, 0x00, 0x00, 0x04, |
2509 0x00, 0x00, 0x00, 0x00, | 2527 0x00, 0x00, 0x00, 0x00, |
2510 }; | 2528 }; |
2511 const unsigned char kV3FrameData[] = { | 2529 const unsigned char kV3FrameData[] = { |
2512 0x80, spdy_version_, 0x00, 0x07, | 2530 0x80, spdy_version_, 0x00, 0x07, |
2513 0x00, 0x00, 0x00, 0x08, | 2531 0x00, 0x00, 0x00, 0x08, |
2514 0x00, 0x00, 0x00, 0x00, | 2532 0x00, 0x00, 0x00, 0x00, |
2515 0x00, 0x00, 0x00, 0x00, | 2533 0x00, 0x00, 0x00, 0x00, |
2516 }; | 2534 }; |
2517 const unsigned char kV4FrameData[] = { | 2535 const unsigned char kV4FrameData[] = { |
2518 0x00, 0x0c, 0x07, 0x00, | 2536 0x00, 0x10, 0x07, 0x00, |
| 2537 0x00, 0x00, 0x00, 0x00, |
2519 0x00, 0x00, 0x00, 0x00, | 2538 0x00, 0x00, 0x00, 0x00, |
2520 0x00, 0x00, 0x00, 0x00, | 2539 0x00, 0x00, 0x00, 0x00, |
2521 }; | 2540 }; |
2522 scoped_ptr<SpdyFrame> frame(framer.CreateGoAway(0, GOAWAY_OK)); | 2541 scoped_ptr<SpdyFrame> frame(framer.CreateGoAway(0, GOAWAY_OK)); |
2523 if (IsSpdy2()) { | 2542 if (IsSpdy2()) { |
2524 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); | 2543 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); |
2525 } else if (IsSpdy3()) { | 2544 } else if (IsSpdy3()) { |
2526 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2545 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
2527 } else { | 2546 } else { |
2528 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2547 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
2529 } | 2548 } |
2530 } | 2549 } |
2531 | 2550 |
2532 { | 2551 { |
2533 const char kDescription[] = "GOAWAY frame with max stream ID, status"; | 2552 const char kDescription[] = "GOAWAY frame with max stream ID, status"; |
2534 const unsigned char kV2FrameData[] = { | 2553 const unsigned char kV2FrameData[] = { |
2535 0x80, spdy_version_, 0x00, 0x07, | 2554 0x80, spdy_version_, 0x00, 0x07, |
2536 0x00, 0x00, 0x00, 0x04, | 2555 0x00, 0x00, 0x00, 0x04, |
2537 0x7f, 0xff, 0xff, 0xff, | 2556 0x7f, 0xff, 0xff, 0xff, |
2538 }; | 2557 }; |
2539 const unsigned char kV3FrameData[] = { | 2558 const unsigned char kV3FrameData[] = { |
2540 0x80, spdy_version_, 0x00, 0x07, | 2559 0x80, spdy_version_, 0x00, 0x07, |
2541 0x00, 0x00, 0x00, 0x08, | 2560 0x00, 0x00, 0x00, 0x08, |
2542 0x7f, 0xff, 0xff, 0xff, | 2561 0x7f, 0xff, 0xff, 0xff, |
2543 0x00, 0x00, 0x00, 0x02, | 2562 0x00, 0x00, 0x00, 0x02, |
2544 }; | 2563 }; |
2545 const unsigned char kV4FrameData[] = { | 2564 const unsigned char kV4FrameData[] = { |
2546 0x00, 0x0c, 0x07, 0x00, | 2565 0x00, 0x10, 0x07, 0x00, |
| 2566 0x00, 0x00, 0x00, 0x00, |
2547 0x7f, 0xff, 0xff, 0xff, | 2567 0x7f, 0xff, 0xff, 0xff, |
2548 0x00, 0x00, 0x00, 0x02, | 2568 0x00, 0x00, 0x00, 0x02, |
2549 }; | 2569 }; |
2550 scoped_ptr<SpdyFrame> frame(framer.CreateGoAway(0x7FFFFFFF, | 2570 scoped_ptr<SpdyFrame> frame(framer.CreateGoAway(0x7FFFFFFF, |
2551 GOAWAY_INTERNAL_ERROR)); | 2571 GOAWAY_INTERNAL_ERROR)); |
2552 if (IsSpdy2()) { | 2572 if (IsSpdy2()) { |
2553 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); | 2573 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); |
2554 } else if (IsSpdy3()) { | 2574 } else if (IsSpdy3()) { |
2555 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2575 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
2556 } else { | 2576 } else { |
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3263 0x00, 0x00, 0x00, 0x1C, | 3283 0x00, 0x00, 0x00, 0x1C, |
3264 0x00, 0x00, 0x00, 0x03, | 3284 0x00, 0x00, 0x00, 0x03, |
3265 0x00, 0x00, 0x00, 0x01, // 1st Setting | 3285 0x00, 0x00, 0x00, 0x01, // 1st Setting |
3266 0x00, 0x00, 0x00, 0x02, | 3286 0x00, 0x00, 0x00, 0x02, |
3267 0x00, 0x00, 0x00, 0x01, // 2nd (duplicate) Setting | 3287 0x00, 0x00, 0x00, 0x01, // 2nd (duplicate) Setting |
3268 0x00, 0x00, 0x00, 0x03, | 3288 0x00, 0x00, 0x00, 0x03, |
3269 0x00, 0x00, 0x00, 0x03, // 3rd (unprocessed) Setting | 3289 0x00, 0x00, 0x00, 0x03, // 3rd (unprocessed) Setting |
3270 0x00, 0x00, 0x00, 0x03, | 3290 0x00, 0x00, 0x00, 0x03, |
3271 }; | 3291 }; |
3272 const unsigned char kV4FrameData[] = { | 3292 const unsigned char kV4FrameData[] = { |
3273 0x00, 0x20, 0x04, 0x00, | 3293 0x00, 0x24, 0x04, 0x00, |
| 3294 0x00, 0x00, 0x00, 0x00, |
3274 0x00, 0x00, 0x00, 0x03, | 3295 0x00, 0x00, 0x00, 0x03, |
3275 0x00, 0x00, 0x00, 0x01, // 1st Setting | 3296 0x00, 0x00, 0x00, 0x01, // 1st Setting |
3276 0x00, 0x00, 0x00, 0x02, | 3297 0x00, 0x00, 0x00, 0x02, |
3277 0x00, 0x00, 0x00, 0x01, // 2nd (duplicate) Setting | 3298 0x00, 0x00, 0x00, 0x01, // 2nd (duplicate) Setting |
3278 0x00, 0x00, 0x00, 0x03, | 3299 0x00, 0x00, 0x00, 0x03, |
3279 0x00, 0x00, 0x00, 0x03, // 3rd (unprocessed) Setting | 3300 0x00, 0x00, 0x00, 0x03, // 3rd (unprocessed) Setting |
3280 0x00, 0x00, 0x00, 0x03, | 3301 0x00, 0x00, 0x00, 0x03, |
3281 }; | 3302 }; |
3282 | 3303 |
3283 TestSpdyVisitor visitor(spdy_version_); | 3304 TestSpdyVisitor visitor(spdy_version_); |
(...skipping 29 matching lines...) Expand all Loading... |
3313 0x00, 0x00, 0x00, 0x1C, | 3334 0x00, 0x00, 0x00, 0x1C, |
3314 0x00, 0x00, 0x00, 0x03, | 3335 0x00, 0x00, 0x00, 0x03, |
3315 0x00, 0x00, 0x00, 0x02, // 1st Setting | 3336 0x00, 0x00, 0x00, 0x02, // 1st Setting |
3316 0x00, 0x00, 0x00, 0x02, | 3337 0x00, 0x00, 0x00, 0x02, |
3317 0x00, 0x00, 0x00, 0x01, // 2nd (out of order) Setting | 3338 0x00, 0x00, 0x00, 0x01, // 2nd (out of order) Setting |
3318 0x00, 0x00, 0x00, 0x03, | 3339 0x00, 0x00, 0x00, 0x03, |
3319 0x00, 0x00, 0x01, 0x03, // 3rd (unprocessed) Setting | 3340 0x00, 0x00, 0x01, 0x03, // 3rd (unprocessed) Setting |
3320 0x00, 0x00, 0x00, 0x03, | 3341 0x00, 0x00, 0x00, 0x03, |
3321 }; | 3342 }; |
3322 const unsigned char kV4FrameData[] = { | 3343 const unsigned char kV4FrameData[] = { |
3323 0x00, 0x20, 0x04, 0x00, | 3344 0x00, 0x24, 0x04, 0x00, |
| 3345 0x00, 0x00, 0x00, 0x00, |
3324 0x00, 0x00, 0x00, 0x03, | 3346 0x00, 0x00, 0x00, 0x03, |
3325 0x00, 0x00, 0x00, 0x02, // 1st Setting | 3347 0x00, 0x00, 0x00, 0x02, // 1st Setting |
3326 0x00, 0x00, 0x00, 0x02, | 3348 0x00, 0x00, 0x00, 0x02, |
3327 0x00, 0x00, 0x00, 0x01, // 2nd (out of order) Setting | 3349 0x00, 0x00, 0x00, 0x01, // 2nd (out of order) Setting |
3328 0x00, 0x00, 0x00, 0x03, | 3350 0x00, 0x00, 0x00, 0x03, |
3329 0x00, 0x00, 0x01, 0x03, // 3rd (unprocessed) Setting | 3351 0x00, 0x00, 0x01, 0x03, // 3rd (unprocessed) Setting |
3330 0x00, 0x00, 0x00, 0x03, | 3352 0x00, 0x00, 0x00, 0x03, |
3331 }; | 3353 }; |
3332 | 3354 |
3333 TestSpdyVisitor visitor(spdy_version_); | 3355 TestSpdyVisitor visitor(spdy_version_); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3500 TestSpdyVisitor visitor(spdy_version_); | 3522 TestSpdyVisitor visitor(spdy_version_); |
3501 visitor.use_compression_ = false; | 3523 visitor.use_compression_ = false; |
3502 visitor.SimulateInFramer(kFrameData, arraysize(kFrameData)); | 3524 visitor.SimulateInFramer(kFrameData, arraysize(kFrameData)); |
3503 EXPECT_EQ(1, visitor.error_count_); | 3525 EXPECT_EQ(1, visitor.error_count_); |
3504 } | 3526 } |
3505 | 3527 |
3506 TEST_P(SpdyFramerTest, SizesTest) { | 3528 TEST_P(SpdyFramerTest, SizesTest) { |
3507 SpdyFramer framer(spdy_version_); | 3529 SpdyFramer framer(spdy_version_); |
3508 EXPECT_EQ(8u, framer.GetDataFrameMinimumSize()); | 3530 EXPECT_EQ(8u, framer.GetDataFrameMinimumSize()); |
3509 if (IsSpdy4()) { | 3531 if (IsSpdy4()) { |
3510 EXPECT_EQ(4u, framer.GetControlFrameHeaderSize()); | |
3511 EXPECT_EQ(14u, framer.GetSynStreamMinimumSize()); | |
3512 EXPECT_EQ(8u, framer.GetSynReplyMinimumSize()); | 3532 EXPECT_EQ(8u, framer.GetSynReplyMinimumSize()); |
3513 EXPECT_EQ(12u, framer.GetRstStreamSize()); | 3533 EXPECT_EQ(12u, framer.GetRstStreamSize()); |
3514 EXPECT_EQ(8u, framer.GetSettingsMinimumSize()); | 3534 EXPECT_EQ(12u, framer.GetSettingsMinimumSize()); |
3515 EXPECT_EQ(8u, framer.GetPingSize()); | 3535 EXPECT_EQ(12u, framer.GetPingSize()); |
3516 EXPECT_EQ(12u, framer.GetGoAwaySize()); | 3536 EXPECT_EQ(16u, framer.GetGoAwaySize()); |
3517 EXPECT_EQ(8u, framer.GetHeadersMinimumSize()); | 3537 EXPECT_EQ(8u, framer.GetHeadersMinimumSize()); |
3518 EXPECT_EQ(12u, framer.GetWindowUpdateSize()); | 3538 EXPECT_EQ(12u, framer.GetWindowUpdateSize()); |
3519 EXPECT_EQ(6u, framer.GetCredentialMinimumSize()); | 3539 EXPECT_EQ(10u, framer.GetCredentialMinimumSize()); |
3520 EXPECT_EQ(4u, framer.GetFrameMinimumSize()); | 3540 EXPECT_EQ(8u, framer.GetFrameMinimumSize()); |
3521 EXPECT_EQ(65535u, framer.GetFrameMaximumSize()); | 3541 EXPECT_EQ(65535u, framer.GetFrameMaximumSize()); |
3522 EXPECT_EQ(65527u, framer.GetDataFrameMaximumPayload()); | 3542 EXPECT_EQ(65527u, framer.GetDataFrameMaximumPayload()); |
3523 } else { | 3543 } else { |
3524 EXPECT_EQ(8u, framer.GetControlFrameHeaderSize()); | 3544 EXPECT_EQ(8u, framer.GetControlFrameHeaderSize()); |
3525 EXPECT_EQ(18u, framer.GetSynStreamMinimumSize()); | 3545 EXPECT_EQ(18u, framer.GetSynStreamMinimumSize()); |
3526 EXPECT_EQ(IsSpdy2() ? 14u : 12u, framer.GetSynReplyMinimumSize()); | 3546 EXPECT_EQ(IsSpdy2() ? 14u : 12u, framer.GetSynReplyMinimumSize()); |
3527 EXPECT_EQ(16u, framer.GetRstStreamSize()); | 3547 EXPECT_EQ(16u, framer.GetRstStreamSize()); |
3528 EXPECT_EQ(12u, framer.GetSettingsMinimumSize()); | 3548 EXPECT_EQ(12u, framer.GetSettingsMinimumSize()); |
3529 EXPECT_EQ(12u, framer.GetPingSize()); | 3549 EXPECT_EQ(12u, framer.GetPingSize()); |
3530 EXPECT_EQ(IsSpdy2() ? 12u : 16u, framer.GetGoAwaySize()); | 3550 EXPECT_EQ(IsSpdy2() ? 12u : 16u, framer.GetGoAwaySize()); |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4117 0x00, 0x00, 0x00, 0x04, | 4137 0x00, 0x00, 0x00, 0x04, |
4118 0xff, 0xff, 0xff, 0xff, | 4138 0xff, 0xff, 0xff, 0xff, |
4119 }; | 4139 }; |
4120 const unsigned char kV3FrameData[] = { | 4140 const unsigned char kV3FrameData[] = { |
4121 0x80, spdy_version_, 0x00, 0x07, | 4141 0x80, spdy_version_, 0x00, 0x07, |
4122 0x00, 0x00, 0x00, 0x08, | 4142 0x00, 0x00, 0x00, 0x08, |
4123 0xff, 0xff, 0xff, 0xff, | 4143 0xff, 0xff, 0xff, 0xff, |
4124 0x00, 0x00, 0x00, 0x00, | 4144 0x00, 0x00, 0x00, 0x00, |
4125 }; | 4145 }; |
4126 const unsigned char kV4FrameData[] = { | 4146 const unsigned char kV4FrameData[] = { |
4127 0x00, 0x0c, 0x07, 0x00, | 4147 0x00, 0x10, 0x07, 0x00, |
| 4148 0x00, 0x00, 0x00, 0x00, |
4128 0xff, 0xff, 0xff, 0xff, | 4149 0xff, 0xff, 0xff, 0xff, |
4129 0x00, 0x00, 0x00, 0x00, | 4150 0x00, 0x00, 0x00, 0x00, |
4130 }; | 4151 }; |
4131 | 4152 |
4132 testing::StrictMock<test::MockVisitor> visitor; | 4153 testing::StrictMock<test::MockVisitor> visitor; |
4133 SpdyFramer framer(spdy_version_); | 4154 SpdyFramer framer(spdy_version_); |
4134 framer.set_visitor(&visitor); | 4155 framer.set_visitor(&visitor); |
4135 | 4156 |
4136 EXPECT_CALL(visitor, OnGoAway(0x7fffffff, GOAWAY_OK)); | 4157 EXPECT_CALL(visitor, OnGoAway(0x7fffffff, GOAWAY_OK)); |
4137 if (IsSpdy2()) { | 4158 if (IsSpdy2()) { |
4138 framer.ProcessInput(reinterpret_cast<const char*>(kV2FrameData), | 4159 framer.ProcessInput(reinterpret_cast<const char*>(kV2FrameData), |
4139 arraysize(kV2FrameData)); | 4160 arraysize(kV2FrameData)); |
4140 } else if (IsSpdy3()) { | 4161 } else if (IsSpdy3()) { |
4141 framer.ProcessInput(reinterpret_cast<const char*>(kV3FrameData), | 4162 framer.ProcessInput(reinterpret_cast<const char*>(kV3FrameData), |
4142 arraysize(kV3FrameData)); | 4163 arraysize(kV3FrameData)); |
4143 } else { | 4164 } else { |
4144 framer.ProcessInput(reinterpret_cast<const char*>(kV4FrameData), | 4165 framer.ProcessInput(reinterpret_cast<const char*>(kV4FrameData), |
4145 arraysize(kV4FrameData)); | 4166 arraysize(kV4FrameData)); |
4146 } | 4167 } |
4147 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); | 4168 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); |
4148 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()); | 4169 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()); |
4149 } | 4170 } |
4150 | 4171 |
4151 } // namespace net | 4172 } // namespace net |
OLD | NEW |