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 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 string value("value1\0value2", 13); | 900 string value("value1\0value2", 13); |
901 if (IsSpdy2()) { | 901 if (IsSpdy2()) { |
902 frame.WriteUInt16(1); // Number of headers. | 902 frame.WriteUInt16(1); // Number of headers. |
903 frame.WriteString("name"); | 903 frame.WriteString("name"); |
904 frame.WriteString(value); | 904 frame.WriteString(value); |
905 } else if (spdy_version_ > SPDY3) { | 905 } else if (spdy_version_ > SPDY3) { |
906 // TODO(jgraettinger): If this pattern appears again, move to test class. | 906 // TODO(jgraettinger): If this pattern appears again, move to test class. |
907 std::map<string, string> header_set; | 907 std::map<string, string> header_set; |
908 header_set["name"] = value; | 908 header_set["name"] = value; |
909 string buffer; | 909 string buffer; |
910 HpackEncoder encoder; | 910 HpackEncoder encoder(ObtainHpackHuffmanTable()); |
911 encoder.EncodeHeaderSet(header_set, &buffer); | 911 encoder.EncodeHeaderSetWithoutCompression(header_set, &buffer); |
912 frame.WriteBytes(&buffer[0], buffer.size()); | 912 frame.WriteBytes(&buffer[0], buffer.size()); |
913 } else { | 913 } else { |
914 frame.WriteUInt32(1); // Number of headers. | 914 frame.WriteUInt32(1); // Number of headers. |
915 frame.WriteStringPiece32("name"); | 915 frame.WriteStringPiece32("name"); |
916 frame.WriteStringPiece32(value); | 916 frame.WriteStringPiece32(value); |
917 } | 917 } |
918 // write the length | 918 // write the length |
919 frame.RewriteLength(framer); | 919 frame.RewriteLength(framer); |
920 | 920 |
921 framer.set_enable_compression(false); | 921 framer.set_enable_compression(false); |
(...skipping 2066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2988 | 2988 |
2989 scoped_ptr<SpdySerializedFrame> frame_serialized( | 2989 scoped_ptr<SpdySerializedFrame> frame_serialized( |
2990 framer.SerializeBlocked(SpdyBlockedIR(kStreamId))); | 2990 framer.SerializeBlocked(SpdyBlockedIR(kStreamId))); |
2991 SpdyBlockedIR blocked_ir(kStreamId); | 2991 SpdyBlockedIR blocked_ir(kStreamId); |
2992 scoped_ptr<SpdySerializedFrame> frame_created( | 2992 scoped_ptr<SpdySerializedFrame> frame_created( |
2993 framer.SerializeFrame(blocked_ir)); | 2993 framer.SerializeFrame(blocked_ir)); |
2994 | 2994 |
2995 CompareFrames(kDescription, *frame_serialized, *frame_created); | 2995 CompareFrames(kDescription, *frame_serialized, *frame_created); |
2996 } | 2996 } |
2997 | 2997 |
2998 TEST_P(SpdyFramerTest, CreatePushPromise) { | 2998 TEST_P(SpdyFramerTest, CreatePushPromiseUncompressed) { |
2999 if (spdy_version_ < SPDY4) { | 2999 if (spdy_version_ < SPDY4) { |
3000 return; | 3000 return; |
3001 } | 3001 } |
3002 | 3002 |
3003 SpdyFramer framer(spdy_version_); | 3003 SpdyFramer framer(spdy_version_); |
3004 | 3004 framer.set_enable_compression(false); |
3005 const char kDescription[] = "PUSH_PROMISE frame"; | 3005 const char kDescription[] = "PUSH_PROMISE frame"; |
3006 | 3006 |
3007 const unsigned char kFrameData[] = { | 3007 const unsigned char kFrameData[] = { |
3008 0x00, 0x16, 0x05, 0x04, // PUSH_PROMISE: END_HEADERS | 3008 0x00, 0x16, 0x05, 0x04, // PUSH_PROMISE: END_HEADERS |
3009 0x00, 0x00, 0x00, 0x2a, // Stream 42 | 3009 0x00, 0x00, 0x00, 0x2a, // Stream 42 |
3010 0x00, 0x00, 0x00, 0x39, // Promised stream 57 | 3010 0x00, 0x00, 0x00, 0x39, // Promised stream 57 |
3011 0x40, 0x03, 0x62, 0x61, // @.ba | 3011 0x40, 0x03, 0x62, 0x61, // @.ba |
3012 0x72, 0x03, 0x66, 0x6f, // r.fo | 3012 0x72, 0x03, 0x66, 0x6f, // r.fo |
3013 0x6f, 0x40, 0x03, 0x66, // o@.f | 3013 0x6f, 0x40, 0x03, 0x66, // o@.f |
3014 0x6f, 0x6f, 0x03, 0x62, // oo.b | 3014 0x6f, 0x6f, 0x03, 0x62, // oo.b |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3731 multiple_frame_data.append(string(control_frame->data(), | 3731 multiple_frame_data.append(string(control_frame->data(), |
3732 control_frame->size())); | 3732 control_frame->size())); |
3733 visitor.SimulateInFramer( | 3733 visitor.SimulateInFramer( |
3734 reinterpret_cast<unsigned const char*>(multiple_frame_data.data()), | 3734 reinterpret_cast<unsigned const char*>(multiple_frame_data.data()), |
3735 multiple_frame_data.length()); | 3735 multiple_frame_data.length()); |
3736 EXPECT_EQ(0, visitor.error_count_); | 3736 EXPECT_EQ(0, visitor.error_count_); |
3737 EXPECT_EQ(1u, visitor.last_window_update_stream_); | 3737 EXPECT_EQ(1u, visitor.last_window_update_stream_); |
3738 EXPECT_EQ(2u, visitor.last_window_update_delta_); | 3738 EXPECT_EQ(2u, visitor.last_window_update_delta_); |
3739 } | 3739 } |
3740 | 3740 |
3741 TEST_P(SpdyFramerTest, CreateContinuation) { | 3741 TEST_P(SpdyFramerTest, CreateContinuationUncompressed) { |
3742 if (spdy_version_ < SPDY4) { | 3742 if (spdy_version_ < SPDY4) { |
3743 return; | 3743 return; |
3744 } | 3744 } |
3745 | 3745 |
3746 SpdyFramer framer(spdy_version_); | 3746 SpdyFramer framer(spdy_version_); |
3747 | 3747 framer.set_enable_compression(false); |
3748 const char kDescription[] = "CONTINUATION frame"; | 3748 const char kDescription[] = "CONTINUATION frame"; |
3749 | 3749 |
3750 const unsigned char kFrameData[] = { | 3750 const unsigned char kFrameData[] = { |
3751 0x00, 0x12, 0x09, 0x00, // CONTINUATION | 3751 0x00, 0x12, 0x09, 0x00, // CONTINUATION |
3752 0x00, 0x00, 0x00, 0x2a, // Stream 42 | 3752 0x00, 0x00, 0x00, 0x2a, // Stream 42 |
3753 0x40, 0x03, 0x62, 0x61, // @.ba | 3753 0x40, 0x03, 0x62, 0x61, // @.ba |
3754 0x72, 0x03, 0x66, 0x6f, // r.fo | 3754 0x72, 0x03, 0x66, 0x6f, // r.fo |
3755 0x6f, 0x40, 0x03, 0x66, // o@.f | 3755 0x6f, 0x40, 0x03, 0x66, // o@.f |
3756 0x6f, 0x6f, 0x03, 0x62, // oo.b | 3756 0x6f, 0x6f, 0x03, 0x62, // oo.b |
3757 0x61, 0x72, // ar | 3757 0x61, 0x72, // ar |
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5030 SpdyBlockedIR blocked_ir(0); | 5030 SpdyBlockedIR blocked_ir(0); |
5031 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir)); | 5031 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir)); |
5032 framer.ProcessInput(frame->data(), framer.GetBlockedSize()); | 5032 framer.ProcessInput(frame->data(), framer.GetBlockedSize()); |
5033 | 5033 |
5034 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); | 5034 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); |
5035 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) | 5035 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) |
5036 << SpdyFramer::ErrorCodeToString(framer.error_code()); | 5036 << SpdyFramer::ErrorCodeToString(framer.error_code()); |
5037 } | 5037 } |
5038 | 5038 |
5039 } // namespace net | 5039 } // namespace net |
OLD | NEW |