1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/spdy/spdy_websocket_test_util.h"
7 #include "net/spdy/spdy_framer.h"
8 #include "net/spdy/spdy_http_utils.h"
9 #include "net/spdy/spdy_test_util.h"
11 static const int kDefaultAssociatedStreamId
= 0;
12 static const bool kDefaultCompressed
= false;
13 static const char* const kDefaultDataPointer
= NULL
;
14 static const uint32 kDefaultDataLength
= 0;
15 static const char** const kDefaultExtraHeaders
= NULL
;
16 static const int kDefaultExtraHeaderCount
= 0;
20 spdy::SpdyFrame
* ConstructSpdyWebSocketHandshakeRequestFrame(
21 const char* const headers
[],
23 spdy::SpdyStreamId stream_id
,
24 RequestPriority request_priority
) {
26 // SPDY SYN_STREAM control frame header.
27 const SpdyHeaderInfo kSynStreamHeader
= {
30 kDefaultAssociatedStreamId
,
31 ConvertRequestPriorityToSpdyPriority(request_priority
),
32 spdy::CONTROL_FLAG_NONE
,
40 // Construct SPDY SYN_STREAM control frame.
41 return ConstructSpdyPacket(
44 kDefaultExtraHeaderCount
,
49 spdy::SpdyFrame
* ConstructSpdyWebSocketHandshakeResponseFrame(
50 const char* const headers
[],
52 spdy::SpdyStreamId stream_id
,
53 RequestPriority request_priority
) {
55 // SPDY SYN_REPLY control frame header.
56 const SpdyHeaderInfo kSynReplyHeader
= {
59 kDefaultAssociatedStreamId
,
60 ConvertRequestPriorityToSpdyPriority(request_priority
),
61 spdy::CONTROL_FLAG_NONE
,
69 // Construct SPDY SYN_REPLY control frame.
70 return ConstructSpdyPacket(
73 kDefaultExtraHeaderCount
,
78 spdy::SpdyFrame
* ConstructSpdyWebSocketDataFrame(
81 spdy::SpdyStreamId stream_id
,
84 // Construct SPDY data frame.
85 spdy::SpdyFramer framer
;
86 return framer
.CreateDataFrame(
90 fin
? spdy::DATA_FLAG_FIN
: spdy::DATA_FLAG_NONE
);