diff options
Diffstat (limited to 'net/spdy/spdy_test_util.h')
-rw-r--r-- | net/spdy/spdy_test_util.h | 108 |
1 files changed, 34 insertions, 74 deletions
diff --git a/net/spdy/spdy_test_util.h b/net/spdy/spdy_test_util.h index 3aa45ab..0ac8308 100644 --- a/net/spdy/spdy_test_util.h +++ b/net/spdy/spdy_test_util.h @@ -11,78 +11,6 @@ namespace net { -const uint8 kGetBodyFrame[] = { - 0x00, 0x00, 0x00, 0x01, // header - 0x01, 0x00, 0x00, 0x06, // FIN, length - 'h', 'e', 'l', 'l', 'o', '!', // "hello" -}; - -const uint8 kGetSynCompressed[] = { - 0x80, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x47, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0xc0, 0x00, 0x38, 0xea, 0xdf, 0xa2, 0x51, 0xb2, - 0x62, 0x60, 0x66, 0x60, 0xcb, 0x05, 0xe6, 0xc3, - 0xfc, 0x14, 0x06, 0x66, 0x77, 0xd7, 0x10, 0x06, - 0x66, 0x90, 0xa0, 0x58, 0x46, 0x49, 0x49, 0x81, - 0x95, 0xbe, 0x3e, 0x30, 0xe2, 0xf5, 0xd2, 0xf3, - 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0x92, 0xf3, 0x73, - 0xf5, 0x19, 0xd8, 0xa1, 0x1a, 0x19, 0x38, 0x60, - 0xe6, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff -}; - -const uint8 kPostSyn[] = { - 0x80, 0x01, 0x00, 0x01, // header - 0x00, 0x00, 0x00, 0x4a, // flags, len - 0x00, 0x00, 0x00, 0x01, // stream id - 0x00, 0x00, 0x00, 0x00, // associated - 0xc0, 0x00, 0x00, 0x03, // 4 headers - 0x00, 0x06, 'm', 'e', 't', 'h', 'o', 'd', - 0x00, 0x04, 'P', 'O', 'S', 'T', - 0x00, 0x03, 'u', 'r', 'l', - 0x00, 0x16, 'h', 't', 't', 'p', ':', '/', '/', 'w', 'w', 'w', - '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'c', 'o', - 'm', '/', - 0x00, 0x07, 'v', 'e', 'r', 's', 'i', 'o', 'n', - 0x00, 0x08, 'H', 'T', 'T', 'P', '/', '1', '.', '1', -}; - -const uint8 kPostUploadFrame[] = { - 0x00, 0x00, 0x00, 0x01, // header - 0x01, 0x00, 0x00, 0x0c, // FIN flag - 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '\0' -}; - -// The response -const uint8 kPostSynReply[] = { - 0x80, 0x01, 0x00, 0x02, // header - 0x00, 0x00, 0x00, 0x45, - 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x04, // 4 headers - 0x00, 0x05, 'h', 'e', 'l', 'l', 'o', // "hello" - 0x00, 0x03, 'b', 'y', 'e', // "bye" - 0x00, 0x06, 's', 't', 'a', 't', 'u', 's', // "status" - 0x00, 0x03, '2', '0', '0', // "200" - 0x00, 0x03, 'u', 'r', 'l', // "url" - // "/index.php" - 0x00, 0x0a, '/', 'i', 'n', 'd', 'e', 'x', '.', 'p', 'h', 'p', - 0x00, 0x07, 'v', 'e', 'r', 's', 'i', 'o', 'n', // "version" - 0x00, 0x08, 'H', 'T', 'T', 'P', '/', '1', '.', '1', // "HTTP/1.1" -}; - -const uint8 kPostBodyFrame[] = { - 0x00, 0x00, 0x00, 0x01, // header - 0x01, 0x00, 0x00, 0x06, // FIN, length - 'h', 'e', 'l', 'l', 'o', '!', // "hello" -}; - -const uint8 kGoAway[] = { - 0x80, 0x01, 0x00, 0x07, // header - 0x00, 0x00, 0x00, 0x04, // flags, len - 0x00, 0x00, 0x00, 0x00, // last-accepted-stream-id -}; - -// ---------------------------------------------------------------------------- - // NOTE: In GCC, on a Mac, this can't be in an anonymous namespace! // This struct holds information used to construct spdy control and data frames. struct SpdyHeaderInfo { @@ -156,7 +84,7 @@ int AppendToBuffer(int val, // |tail| is any (relatively constant) header-value pairs to add. // |buffer| is the buffer we're filling in. // Returns a SpdyFrame. -spdy::SpdyFrame* ConstructSpdyPacket(const SpdyHeaderInfo* header_info, +spdy::SpdyFrame* ConstructSpdyPacket(const SpdyHeaderInfo& header_info, const char* const extra_headers[], int extra_header_count, const char* const tail[], @@ -177,6 +105,10 @@ int ConstructSpdyReplyString(const char* const extra_headers[], // Returns the constructed frame. The caller takes ownership of the frame. spdy::SpdyFrame* ConstructSpdySettings(spdy::SpdySettings settings); +// Construct a SPDY GOAWAY frame. +// Returns the constructed frame. The caller takes ownership of the frame. +spdy::SpdyFrame* ConstructSpdyGoAway(); + // Construct a single SPDY header entry, for validation. // |extra_headers| are the extra header-value pairs. // |buffer| is the buffer we're filling in. @@ -188,7 +120,15 @@ int ConstructSpdyHeader(const char* const extra_headers[], int buffer_length, int index); -// Constructs a standard SPDY GET packet. +// Constructs a standard SPDY GET SYN packet, optionally compressed. +// |extra_headers| are the extra header-value pairs, which typically +// will vary the most between calls. +// Returns a SpdyFrame. +spdy::SpdyFrame* ConstructSpdyGet(const char* const extra_headers[], + int extra_header_count, + bool compressed); + +// Constructs a standard SPDY GET SYN packet, with no compression. // |extra_headers| are the extra header-value pairs, which typically // will vary the most between calls. // Returns a SpdyFrame. @@ -202,9 +142,29 @@ spdy::SpdyFrame* ConstructSpdyGet(const char* const extra_headers[], spdy::SpdyFrame* ConstructSpdyGetSynReply(const char* const extra_headers[], int extra_header_count); +// Constructs a standard SPDY POST SYN packet. +// |extra_headers| are the extra header-value pairs, which typically +// will vary the most between calls. +// Returns a SpdyFrame. +spdy::SpdyFrame* ConstructSpdyPost(const char* const extra_headers[], + int extra_header_count); + +// Constructs a standard SPDY SYN_REPLY packet to match the SPDY POST. +// |extra_headers| are the extra header-value pairs, which typically +// will vary the most between calls. +// Returns a SpdyFrame. +spdy::SpdyFrame* ConstructSpdyPostSynReply(const char* const extra_headers[], + int extra_header_count); + +// Constructs a single SPDY data frame with the contents "hello!" +spdy::SpdyFrame* ConstructSpdyBodyFrame(); + // Create an async MockWrite from the given SpdyFrame. MockWrite CreateMockWrite(spdy::SpdyFrame* req); +// Create an async MockWrite from the given SpdyFrame and sequence number. +MockWrite CreateMockWrite(spdy::SpdyFrame* req, int seq); + // Create a MockRead from the given SpdyFrame. MockRead CreateMockRead(spdy::SpdyFrame* resp); |