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 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 frame.WriteUInt32(3); // stream_id | 864 frame.WriteUInt32(3); // stream_id |
865 frame.WriteUInt32(0); // associated stream id | 865 frame.WriteUInt32(0); // associated stream id |
866 frame.WriteUInt16(0); // Priority. | 866 frame.WriteUInt16(0); // Priority. |
867 } else { | 867 } else { |
868 frame.BeginNewFrame(framer, HEADERS, HEADERS_FLAG_PRIORITY, 3); | 868 frame.BeginNewFrame(framer, HEADERS, HEADERS_FLAG_PRIORITY, 3); |
869 frame.WriteUInt32(framer.GetHighestPriority()); | 869 frame.WriteUInt32(framer.GetHighestPriority()); |
870 } | 870 } |
871 | 871 |
872 if (IsSpdy2()) { | 872 if (IsSpdy2()) { |
873 frame.WriteUInt16(2); // Number of headers. | 873 frame.WriteUInt16(2); // Number of headers. |
874 frame.WriteString("name"); | 874 frame.WriteStringPiece16("name"); |
875 frame.WriteString("value1"); | 875 frame.WriteStringPiece16("value1"); |
876 frame.WriteString("name"); | 876 frame.WriteStringPiece16("name"); |
877 frame.WriteString("value2"); | 877 frame.WriteStringPiece16("value2"); |
878 } else { | 878 } else { |
879 frame.WriteUInt32(2); // Number of headers. | 879 frame.WriteUInt32(2); // Number of headers. |
880 frame.WriteStringPiece32("name"); | 880 frame.WriteStringPiece32("name"); |
881 frame.WriteStringPiece32("value1"); | 881 frame.WriteStringPiece32("value1"); |
882 frame.WriteStringPiece32("name"); | 882 frame.WriteStringPiece32("name"); |
883 frame.WriteStringPiece32("value2"); | 883 frame.WriteStringPiece32("value2"); |
884 } | 884 } |
885 // write the length | 885 // write the length |
886 frame.RewriteLength(framer); | 886 frame.RewriteLength(framer); |
887 | 887 |
(...skipping 22 matching lines...) Expand all Loading... |
910 HEADERS, | 910 HEADERS, |
911 HEADERS_FLAG_PRIORITY | HEADERS_FLAG_END_HEADERS, | 911 HEADERS_FLAG_PRIORITY | HEADERS_FLAG_END_HEADERS, |
912 3); | 912 3); |
913 frame.WriteUInt32(0); // Priority exclusivity and dependent stream. | 913 frame.WriteUInt32(0); // Priority exclusivity and dependent stream. |
914 frame.WriteUInt8(255); // Priority weight. | 914 frame.WriteUInt8(255); // Priority weight. |
915 } | 915 } |
916 | 916 |
917 string value("value1\0value2", 13); | 917 string value("value1\0value2", 13); |
918 if (IsSpdy2()) { | 918 if (IsSpdy2()) { |
919 frame.WriteUInt16(1); // Number of headers. | 919 frame.WriteUInt16(1); // Number of headers. |
920 frame.WriteString("name"); | 920 frame.WriteStringPiece16("name"); |
921 frame.WriteString(value); | 921 frame.WriteStringPiece16(value); |
922 } else if (spdy_version_ > SPDY3) { | 922 } else if (spdy_version_ > SPDY3) { |
923 // TODO(jgraettinger): If this pattern appears again, move to test class. | 923 // TODO(jgraettinger): If this pattern appears again, move to test class. |
924 std::map<string, string> header_set; | 924 std::map<string, string> header_set; |
925 header_set["name"] = value; | 925 header_set["name"] = value; |
926 string buffer; | 926 string buffer; |
927 HpackEncoder encoder(ObtainHpackHuffmanTable()); | 927 HpackEncoder encoder(ObtainHpackHuffmanTable()); |
928 encoder.EncodeHeaderSetWithoutCompression(header_set, &buffer); | 928 encoder.EncodeHeaderSetWithoutCompression(header_set, &buffer); |
929 frame.WriteBytes(&buffer[0], buffer.size()); | 929 frame.WriteBytes(&buffer[0], buffer.size()); |
930 } else { | 930 } else { |
931 frame.WriteUInt32(1); // Number of headers. | 931 frame.WriteUInt32(1); // Number of headers. |
(...skipping 5003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5935 TestSpdyVisitor visitor(spdy_version_); | 5935 TestSpdyVisitor visitor(spdy_version_); |
5936 visitor.SimulateInFramer(kFrameData, sizeof(kFrameData)); | 5936 visitor.SimulateInFramer(kFrameData, sizeof(kFrameData)); |
5937 | 5937 |
5938 EXPECT_EQ(SpdyFramer::SPDY_ERROR, visitor.framer_.state()); | 5938 EXPECT_EQ(SpdyFramer::SPDY_ERROR, visitor.framer_.state()); |
5939 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, | 5939 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, |
5940 visitor.framer_.error_code()) | 5940 visitor.framer_.error_code()) |
5941 << SpdyFramer::ErrorCodeToString(visitor.framer_.error_code()); | 5941 << SpdyFramer::ErrorCodeToString(visitor.framer_.error_code()); |
5942 } | 5942 } |
5943 | 5943 |
5944 } // namespace net | 5944 } // namespace net |
OLD | NEW |