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

Unified Diff: net/spdy/spdy_test_util_spdy2.cc

Issue 10810069: SPDY: Add WriteHeaders interface to SpdySession and SpdyStream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for commit Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/spdy/spdy_test_util_spdy2.h ('k') | net/spdy/spdy_test_util_spdy3.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_test_util_spdy2.cc
diff --git a/net/spdy/spdy_test_util_spdy2.cc b/net/spdy/spdy_test_util_spdy2.cc
index 1c08f33f9e1f022734157788f39be892a225a8c2..b9cd38b1567b145f67baef4814f30fd48f9e3cd1 100644
--- a/net/spdy/spdy_test_util_spdy2.cc
+++ b/net/spdy/spdy_test_util_spdy2.cc
@@ -454,6 +454,35 @@ SpdyFrame* ConstructSpdyConnect(const char* const extra_headers[],
arraysize(kConnectHeaders));
}
+// Constructs a standard SPDY SYN_STREAM frame for a WebSocket over SPDY
+// opening handshake.
+SpdyFrame* ConstructSpdyWebSocket(int stream_id,
+ const char* path,
+ const char* host,
+ const char* origin) {
+ const char* const kWebSocketHeaders[] = {
+ "path",
+ path,
+ "host",
+ host,
+ "version",
+ "WebSocket/13",
+ "scheme",
+ "ws",
+ "origin",
+ origin
+ };
+ return ConstructSpdyControlFrame(/*extra_headers*/ NULL,
+ /*extra_header_count*/ 0,
+ /*compressed*/ false,
+ stream_id,
+ LOWEST,
+ SYN_STREAM,
+ CONTROL_FLAG_NONE,
+ kWebSocketHeaders,
+ arraysize(kWebSocketHeaders));
+}
+
// Constructs a standard SPDY push SYN packet.
// |extra_headers| are the extra header-value pairs, which typically
// will vary the most between calls.
@@ -654,6 +683,25 @@ SpdyFrame* ConstructSpdyGetSynReply(const char* const extra_headers[],
arraysize(kStandardGetHeaders));
}
+// Constructs a standard SPDY SYN_REPLY packet to match the WebSocket over SPDY
+// opening handshake.
+// Returns a SpdyFrame.
+SpdyFrame* ConstructSpdyWebSocketSynReply(int stream_id) {
+ static const char* const kStandardWebSocketHeaders[] = {
+ "status",
+ "101"
+ };
+ return ConstructSpdyControlFrame(NULL,
+ 0,
+ false,
+ stream_id,
+ LOWEST,
+ SYN_REPLY,
+ CONTROL_FLAG_NONE,
+ kStandardWebSocketHeaders,
+ arraysize(kStandardWebSocketHeaders));
+}
+
// Constructs a standard SPDY POST SYN packet.
// |content_length| is the size of post data.
// |extra_headers| are the extra header-value pairs, which typically
@@ -760,6 +808,29 @@ SpdyFrame* ConstructSpdyBodyFrame(int stream_id, const char* data,
stream_id, data, len, fin ? DATA_FLAG_FIN : DATA_FLAG_NONE);
}
+// Constructs a SPDY HEADERS frame for a WebSocket frame over SPDY.
+SpdyFrame* ConstructSpdyWebSocketHeadersFrame(int stream_id,
+ const char* length,
+ bool fin) {
+ static const char* const kHeaders[] = {
+ "opcode",
+ "1", // text frame
+ "length",
+ length,
+ "fin",
+ fin ? "1" : "0"
+ };
+ return ConstructSpdyControlFrame(/*extra_headers*/ NULL,
+ /*extra_header_count*/ 0,
+ /*compression*/ false,
+ stream_id,
+ LOWEST,
+ HEADERS,
+ CONTROL_FLAG_NONE,
+ kHeaders,
+ arraysize(kHeaders));
+}
+
// Wraps |frame| in the payload of a data frame in stream |stream_id|.
SpdyFrame* ConstructWrappedSpdyFrame(
const scoped_ptr<SpdyFrame>& frame,
« no previous file with comments | « net/spdy/spdy_test_util_spdy2.h ('k') | net/spdy/spdy_test_util_spdy3.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698