Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(463)

Side by Side Diff: net/spdy/spdy_framer_test.cc

Issue 247793002: HPACK: Refactor and simplify HpackOutputStream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/spdy/hpack_output_stream_test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 3); 896 3);
897 frame.WriteUInt32(framer.GetHighestPriority()); 897 frame.WriteUInt32(framer.GetHighestPriority());
898 } 898 }
899 899
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 HpackOutputStream output_stream(1024); 906 // TODO(jgraettinger): If this pattern appears again, move to test class.
907 output_stream.AppendLiteralHeaderNoIndexingWithName("name", value); 907 std::map<string, string> header_set;
908 header_set["name"] = value;
908 string buffer; 909 string buffer;
909 output_stream.TakeString(&buffer); 910 HpackEncoder encoder;
911 encoder.EncodeHeaderSet(header_set, &buffer);
910 frame.WriteBytes(&buffer[0], buffer.size()); 912 frame.WriteBytes(&buffer[0], buffer.size());
911 } else { 913 } else {
912 frame.WriteUInt32(1); // Number of headers. 914 frame.WriteUInt32(1); // Number of headers.
913 frame.WriteStringPiece32("name"); 915 frame.WriteStringPiece32("name");
914 frame.WriteStringPiece32(value); 916 frame.WriteStringPiece32(value);
915 } 917 }
916 // write the length 918 // write the length
917 frame.RewriteLength(framer); 919 frame.RewriteLength(framer);
918 920
919 framer.set_enable_compression(false); 921 framer.set_enable_compression(false);
(...skipping 4108 matching lines...) Expand 10 before | Expand all | Expand 10 after
5028 SpdyBlockedIR blocked_ir(0); 5030 SpdyBlockedIR blocked_ir(0);
5029 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir)); 5031 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir));
5030 framer.ProcessInput(frame->data(), framer.GetBlockedSize()); 5032 framer.ProcessInput(frame->data(), framer.GetBlockedSize());
5031 5033
5032 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); 5034 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state());
5033 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) 5035 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code())
5034 << SpdyFramer::ErrorCodeToString(framer.error_code()); 5036 << SpdyFramer::ErrorCodeToString(framer.error_code());
5035 } 5037 }
5036 5038
5037 } // namespace net 5039 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/hpack_output_stream_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698