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

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

Issue 17570014: [SPDY] Unfork websocket_handshake_handler_spdy{2,3}_unittest.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 7 years, 5 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "net/spdy/spdy_websocket_test_util.h" 5 #include "net/spdy/spdy_websocket_test_util.h"
6 6
7 #include "net/spdy/buffered_spdy_framer.h" 7 #include "net/spdy/buffered_spdy_framer.h"
8 #include "net/spdy/spdy_http_utils.h" 8 #include "net/spdy/spdy_http_utils.h"
9 9
10 namespace net { 10 namespace net {
11 11
12 static const int kDefaultAssociatedStreamId = 0; 12 static const int kDefaultAssociatedStreamId = 0;
13 static const bool kDefaultCompressed = false; 13 static const bool kDefaultCompressed = false;
14 static const char* const kDefaultDataPointer = NULL; 14 static const char* const kDefaultDataPointer = NULL;
15 static const uint32 kDefaultDataLength = 0; 15 static const uint32 kDefaultDataLength = 0;
16 static const char** const kDefaultExtraHeaders = NULL; 16 static const char** const kDefaultExtraHeaders = NULL;
17 static const int kDefaultExtraHeaderCount = 0; 17 static const int kDefaultExtraHeaderCount = 0;
18 18
19 SpdyWebSocketTestUtil::SpdyWebSocketTestUtil( 19 SpdyWebSocketTestUtil::SpdyWebSocketTestUtil(
20 NextProto protocol) : spdy_util_(protocol) {} 20 NextProto protocol) : spdy_util_(protocol) {}
21 21
22 std::string SpdyWebSocketTestUtil::GetHeader(const SpdyHeaderBlock& headers,
23 const std::string& key) const {
24 SpdyHeaderBlock::const_iterator it = headers.find(GetHeaderKey(key));
25 return (it == headers.end()) ? "" : it->second;
26 }
27
22 void SpdyWebSocketTestUtil::SetHeader( 28 void SpdyWebSocketTestUtil::SetHeader(
23 const std::string& key, 29 const std::string& key,
24 const std::string& value, 30 const std::string& value,
25 SpdyHeaderBlock* headers) const { 31 SpdyHeaderBlock* headers) const {
26 (*headers)[(spdy_util_.is_spdy2() ? "" : ":") + key] = value; 32 (*headers)[GetHeaderKey(key)] = value;
27 } 33 }
28 34
29 SpdyFrame* SpdyWebSocketTestUtil::ConstructSpdyWebSocketSynStream( 35 SpdyFrame* SpdyWebSocketTestUtil::ConstructSpdyWebSocketSynStream(
30 int stream_id, 36 int stream_id,
31 const char* path, 37 const char* path,
32 const char* host, 38 const char* host,
33 const char* origin) { 39 const char* origin) {
34 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock()); 40 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock());
35 SetHeader("path", path, headers.get()); 41 SetHeader("path", path, headers.get());
36 SetHeader("host", host, headers.get()); 42 SetHeader("host", host, headers.get());
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 data, 145 data,
140 len, 146 len,
141 fin ? DATA_FLAG_FIN : DATA_FLAG_NONE); 147 fin ? DATA_FLAG_FIN : DATA_FLAG_NONE);
142 } 148 }
143 149
144 SpdyFrame* SpdyWebSocketTestUtil::ConstructSpdySettings( 150 SpdyFrame* SpdyWebSocketTestUtil::ConstructSpdySettings(
145 const SettingsMap& settings) const { 151 const SettingsMap& settings) const {
146 return spdy_util_.ConstructSpdySettings(settings); 152 return spdy_util_.ConstructSpdySettings(settings);
147 } 153 }
148 154
155 SpdyMajorVersion SpdyWebSocketTestUtil::spdy_version() const {
156 return spdy_util_.spdy_version();
157 }
158
159 std::string SpdyWebSocketTestUtil::GetHeaderKey(
160 const std::string& key) const {
161 return (spdy_util_.is_spdy2() ? "" : ":") + key;
162 }
163
149 } // namespace net 164 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_websocket_test_util.h ('k') | net/websockets/websocket_handshake_handler_spdy2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698