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
3 // found in the LICENSE file.
5 #include "net/spdy/spdy_websocket_test_util_spdy2.h"
7 #include "net/spdy/buffered_spdy_framer.h"
8 #include "net/spdy/spdy_http_utils.h"
9 #include "net/spdy/spdy_test_util_spdy2.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 namespace test_spdy2
{
22 SpdyFrame
* ConstructSpdyWebSocketHandshakeRequestFrame(
23 const char* const headers
[],
25 SpdyStreamId stream_id
,
26 RequestPriority request_priority
) {
28 // SPDY SYN_STREAM control frame header.
29 const SpdyHeaderInfo kSynStreamHeader
= {
32 kDefaultAssociatedStreamId
,
33 ConvertRequestPriorityToSpdyPriority(request_priority
, 2),
42 // Construct SPDY SYN_STREAM control frame.
43 return ConstructSpdyPacket(
46 kDefaultExtraHeaderCount
,
51 SpdyFrame
* ConstructSpdyWebSocketHandshakeResponseFrame(
52 const char* const headers
[],
54 SpdyStreamId stream_id
,
55 RequestPriority request_priority
) {
57 // SPDY SYN_REPLY control frame header.
58 const SpdyHeaderInfo kSynReplyHeader
= {
61 kDefaultAssociatedStreamId
,
62 ConvertRequestPriorityToSpdyPriority(request_priority
, 2),
71 // Construct SPDY SYN_REPLY control frame.
72 return ConstructSpdyPacket(
75 kDefaultExtraHeaderCount
,
80 SpdyFrame
* ConstructSpdyWebSocketDataFrame(
83 SpdyStreamId stream_id
,
86 // Construct SPDY data frame.
87 BufferedSpdyFramer
framer(2);
88 return framer
.CreateDataFrame(
92 fin
? DATA_FLAG_FIN
: DATA_FLAG_NONE
);
95 } // namespace test_spdy2