12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved. 22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file. 42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifndef NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ 62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ 72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 8eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include <string> 9eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include <vector> 10eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/memory/ref_counted.h" 1290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "base/memory/scoped_ptr.h" 13c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "crypto/ec_private_key.h" 14c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "crypto/ec_signature_creator.h" 152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "net/base/completion_callback.h" 162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "net/base/request_priority.h" 172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "net/base/test_completion_callback.h" 18c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "net/cert/cert_verifier.h" 19c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "net/dns/mock_host_resolver.h" 20c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "net/http/http_auth_handler_factory.h" 21c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "net/http/http_network_session.h" 227d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "net/http/http_response_info.h" 23c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "net/http/http_server_properties_impl.h" 247d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "net/http/transport_security_state.h" 25c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "net/proxy/proxy_service.h" 26c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "net/socket/next_proto.h" 27c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "net/socket/socket_test_util.h" 282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "net/spdy/spdy_protocol.h" 29c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "net/ssl/ssl_config_service_defaults.h" 30c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "net/url_request/url_request_context.h" 31c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "net/url_request/url_request_context_storage.h" 32c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "testing/gtest/include/gtest/gtest.h" 332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class GURL; 352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace net { 372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class BoundNetLog; 392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class SpdySession; 407dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdochclass SpdySessionKey; 417dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdochclass SpdySessionPool; 422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class SpdyStream; 432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class SpdyStreamRequest; 442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 45c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Default upload data used by both, mock objects and framer when creating 46c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// data frames. 47c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)const char kDefaultURL[] = "http://www.google.com"; 48c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)const char kUploadData[] = "hello!"; 49c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)const int kUploadDataSize = arraysize(kUploadData)-1; 50c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 51ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch// SpdyNextProtos returns a vector of next protocols for negotiating 52eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch// SPDY. 53cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)NextProtoVector SpdyNextProtos(); 54eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 55c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Chop a frame into an array of MockWrites. 56c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// |data| is the frame to chop. 57c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// |length| is the length of the frame to chop. 58c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// |num_chunks| is the number of chunks to create. 59c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)MockWrite* ChopWriteFrame(const char* data, int length, int num_chunks); 60c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 61c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Chop a SpdyFrame into an array of MockWrites. 62c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// |frame| is the frame to chop. 63c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// |num_chunks| is the number of chunks to create. 64c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)MockWrite* ChopWriteFrame(const SpdyFrame& frame, int num_chunks); 65c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 66c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Chop a frame into an array of MockReads. 67c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// |data| is the frame to chop. 68c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// |length| is the length of the frame to chop. 69c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// |num_chunks| is the number of chunks to create. 70c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)MockRead* ChopReadFrame(const char* data, int length, int num_chunks); 71c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 72c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Chop a SpdyFrame into an array of MockReads. 73c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// |frame| is the frame to chop. 74c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// |num_chunks| is the number of chunks to create. 75c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)MockRead* ChopReadFrame(const SpdyFrame& frame, int num_chunks); 76c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 77c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Adds headers and values to a map. 78c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// |extra_headers| is an array of { name, value } pairs, arranged as strings 79c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// where the even entries are the header names, and the odd entries are the 80c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// header values. 81c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// |headers| gets filled in from |extra_headers|. 82c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)void AppendToHeaderBlock(const char* const extra_headers[], 83c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) int extra_header_count, 84c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SpdyHeaderBlock* headers); 85c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 86c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Create an async MockWrite from the given SpdyFrame. 87c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)MockWrite CreateMockWrite(const SpdyFrame& req); 88c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 89c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Create an async MockWrite from the given SpdyFrame and sequence number. 90c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)MockWrite CreateMockWrite(const SpdyFrame& req, int seq); 91c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 92c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)MockWrite CreateMockWrite(const SpdyFrame& req, int seq, IoMode mode); 93c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 94c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Create a MockRead from the given SpdyFrame. 95c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)MockRead CreateMockRead(const SpdyFrame& resp); 96c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 97c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Create a MockRead from the given SpdyFrame and sequence number. 98c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)MockRead CreateMockRead(const SpdyFrame& resp, int seq); 99c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 100c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)MockRead CreateMockRead(const SpdyFrame& resp, int seq, IoMode mode); 101c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 102c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Combines the given SpdyFrames into the given char array and returns 103c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// the total length. 104c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)int CombineFrames(const SpdyFrame** frames, int num_frames, 105c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) char* buff, int buff_len); 106c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 1072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Returns the SpdyPriority embedded in the given frame. Returns true 1082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// and fills in |priority| on success. 10990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)bool GetSpdyPriority(SpdyMajorVersion version, 1102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const SpdyFrame& frame, 1112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) SpdyPriority* priority); 1122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Tries to create a stream in |session| synchronously. Returns NULL 1142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// on failure. 115a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)base::WeakPtr<SpdyStream> CreateStreamSynchronously( 11690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) SpdyStreamType type, 117ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch const base::WeakPtr<SpdySession>& session, 1182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const GURL& url, 1192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) RequestPriority priority, 1202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const BoundNetLog& net_log); 1212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 122a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// Helper class used by some tests to release a stream as soon as it's 123a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// created. 1242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class StreamReleaserCallback : public TestCompletionCallbackBase { 1252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public: 126a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) StreamReleaserCallback(); 1272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual ~StreamReleaserCallback(); 1292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 130a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Returns a callback that releases |request|'s stream. 1312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CompletionCallback MakeCallback(SpdyStreamRequest* request); 1322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private: 1342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void OnComplete(SpdyStreamRequest* request, int result); 1352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}; 1362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 137c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)const size_t kSpdyCredentialSlotUnused = 0; 138c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 139c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// This struct holds information used to construct spdy control and data frames. 140c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)struct SpdyHeaderInfo { 141c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SpdyFrameType kind; 142c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SpdyStreamId id; 143c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SpdyStreamId assoc_id; 144c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SpdyPriority priority; 145c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) size_t credential_slot; // SPDY3 only 146c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SpdyControlFlags control_flags; 147c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) bool compressed; 148c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SpdyRstStreamStatus status; 149c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) const char* data; 150c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) uint32 data_length; 151c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SpdyDataFlags data_flags; 152c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}; 153c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 154c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// An ECSignatureCreator that returns deterministic signatures. 155c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)class MockECSignatureCreator : public crypto::ECSignatureCreator { 156c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) public: 157c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) explicit MockECSignatureCreator(crypto::ECPrivateKey* key); 158c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 159c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // crypto::ECSignatureCreator 160c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) virtual bool Sign(const uint8* data, 161c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) int data_len, 162c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) std::vector<uint8>* signature) OVERRIDE; 163c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) virtual bool DecodeSignature(const std::vector<uint8>& signature, 164c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) std::vector<uint8>* out_raw_sig) OVERRIDE; 165c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 166c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) private: 167c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) crypto::ECPrivateKey* key_; 168c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 169c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(MockECSignatureCreator); 170c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}; 171c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 172c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// An ECSignatureCreatorFactory creates MockECSignatureCreator. 173c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)class MockECSignatureCreatorFactory : public crypto::ECSignatureCreatorFactory { 174c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) public: 175c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) MockECSignatureCreatorFactory(); 176c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) virtual ~MockECSignatureCreatorFactory(); 177c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 178c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // crypto::ECSignatureCreatorFactory 179c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) virtual crypto::ECSignatureCreator* Create( 180c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) crypto::ECPrivateKey* key) OVERRIDE; 181c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 182c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) private: 183c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(MockECSignatureCreatorFactory); 184c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}; 185c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 186c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Helper to manage the lifetimes of the dependencies for a 187c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// HttpNetworkTransaction. 188c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)struct SpdySessionDependencies { 189c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Default set of dependencies -- "null" proxy service. 190c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) explicit SpdySessionDependencies(NextProto protocol); 191c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 192c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Custom proxy service dependency. 193c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SpdySessionDependencies(NextProto protocol, ProxyService* proxy_service); 194c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 195c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) ~SpdySessionDependencies(); 196c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 197c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) static HttpNetworkSession* SpdyCreateSession( 198c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SpdySessionDependencies* session_deps); 199c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) static HttpNetworkSession* SpdyCreateSessionDeterministic( 200c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SpdySessionDependencies* session_deps); 201c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) static HttpNetworkSession::Params CreateSessionParams( 202c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SpdySessionDependencies* session_deps); 203c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 204c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // NOTE: host_resolver must be ordered before http_auth_handler_factory. 205c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) scoped_ptr<MockHostResolverBase> host_resolver; 206c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) scoped_ptr<CertVerifier> cert_verifier; 2077d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) scoped_ptr<TransportSecurityState> transport_security_state; 208c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) scoped_ptr<ProxyService> proxy_service; 209c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) scoped_refptr<SSLConfigService> ssl_config_service; 210c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) scoped_ptr<MockClientSocketFactory> socket_factory; 211c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) scoped_ptr<DeterministicMockClientSocketFactory> deterministic_socket_factory; 212c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory; 213c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) HttpServerPropertiesImpl http_server_properties; 214c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) bool enable_ip_pooling; 215c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) bool enable_compression; 216c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) bool enable_ping; 217c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) bool enable_user_alternate_protocol_ports; 218c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) NextProto protocol; 219c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) size_t stream_initial_recv_window_size; 220c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SpdySession::TimeFunc time_func; 22146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) NextProtoVector next_protos; 222c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) std::string trusted_spdy_proxy; 22346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) bool force_spdy_over_ssl; 22446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) bool force_spdy_always; 225cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) bool use_alternate_protocols; 22646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) bool enable_websocket_over_spdy; 227c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) NetLog* net_log; 228c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}; 229c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 230c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)class SpdyURLRequestContext : public URLRequestContext { 231c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) public: 232cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) SpdyURLRequestContext(NextProto protocol, 233cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) bool force_spdy_over_ssl, 234cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) bool force_spdy_always); 235c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) virtual ~SpdyURLRequestContext(); 236c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 237c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) MockClientSocketFactory& socket_factory() { return socket_factory_; } 238c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 239c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) private: 240c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) MockClientSocketFactory socket_factory_; 241c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) net::URLRequestContextStorage storage_; 242c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}; 243c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 2447dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch// Equivalent to pool->GetIfExists(spdy_session_key, BoundNetLog()) != NULL. 2457dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdochbool HasSpdySession(SpdySessionPool* pool, const SpdySessionKey& key); 2467dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch 2477dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch// Creates a SPDY session for the given key and puts it in the SPDY 2487dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch// session pool in |http_session|. A SPDY session for |key| must not 2497dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch// already exist. 250ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdochbase::WeakPtr<SpdySession> CreateInsecureSpdySession( 2517dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch const scoped_refptr<HttpNetworkSession>& http_session, 2527dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch const SpdySessionKey& key, 2537dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch const BoundNetLog& net_log); 2547dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch 255ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch// Tries to create a SPDY session for the given key but expects the 256ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch// attempt to fail with the given error. A SPDY session for |key| must 257effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch// not already exist. The session will be created but close in the 258effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch// next event loop iteration. 259effb81e5f8246d0db0270817048dc992db66e9fbBen Murdochbase::WeakPtr<SpdySession> TryCreateInsecureSpdySessionExpectingFailure( 260ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch const scoped_refptr<HttpNetworkSession>& http_session, 261ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch const SpdySessionKey& key, 262ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch Error expected_error, 263ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch const BoundNetLog& net_log); 264ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch 2657dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch// Like CreateInsecureSpdySession(), but uses TLS. 266ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdochbase::WeakPtr<SpdySession> CreateSecureSpdySession( 2677dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch const scoped_refptr<HttpNetworkSession>& http_session, 2687dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch const SpdySessionKey& key, 2697dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch const BoundNetLog& net_log); 2707dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch 2717dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch// Creates an insecure SPDY session for the given key and puts it in 272ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch// |pool|. The returned session will neither receive nor send any 2737dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch// data. A SPDY session for |key| must not already exist. 274ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdochbase::WeakPtr<SpdySession> CreateFakeSpdySession(SpdySessionPool* pool, 2757dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch const SpdySessionKey& key); 2767dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch 277ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch// Tries to create an insecure SPDY session for the given key but 278ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch// expects the attempt to fail with the given error. The session will 279ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch// neither receive nor send any data. A SPDY session for |key| must 280effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch// not already exist. The session will be created but close in the 281effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch// next event loop iteration. 282effb81e5f8246d0db0270817048dc992db66e9fbBen Murdochbase::WeakPtr<SpdySession> TryCreateFakeSpdySessionExpectingFailure( 283effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch SpdySessionPool* pool, 284effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch const SpdySessionKey& key, 285effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch Error expected_error); 286ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch 287c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)class SpdySessionPoolPeer { 288c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) public: 289b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) explicit SpdySessionPoolPeer(SpdySessionPool* pool); 290c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 29190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) void RemoveAliases(const SpdySessionKey& key); 292c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) void DisableDomainAuthenticationVerification(); 293a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) void SetEnableSendingInitialData(bool enabled); 294c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 295c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) private: 296c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SpdySessionPool* const pool_; 297c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 298c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(SpdySessionPoolPeer); 299c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}; 300c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 301b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)class SpdyTestUtil { 302b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) public: 303b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) explicit SpdyTestUtil(NextProto protocol); 304b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) 305868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Add the appropriate headers to put |url| into |block|. 306868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void AddUrlToHeaderBlock(base::StringPiece url, 307868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SpdyHeaderBlock* headers) const; 308868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 309b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) scoped_ptr<SpdyHeaderBlock> ConstructGetHeaderBlock( 310b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) base::StringPiece url) const; 3117d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) scoped_ptr<SpdyHeaderBlock> ConstructGetHeaderBlockForProxy( 3127d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) base::StringPiece url) const; 3137d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) scoped_ptr<SpdyHeaderBlock> ConstructHeadHeaderBlock( 3147d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) base::StringPiece url, 3157d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) int64 content_length) const; 316b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) scoped_ptr<SpdyHeaderBlock> ConstructPostHeaderBlock( 317b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) base::StringPiece url, 318b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) int64 content_length) const; 3197d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) scoped_ptr<SpdyHeaderBlock> ConstructPutHeaderBlock( 3207d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) base::StringPiece url, 3217d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) int64 content_length) const; 322b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) 323b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) // Construct a SPDY frame. If it is a SYN_STREAM or SYN_REPLY frame (as 324b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) // specified in header_info.kind), the provided headers are included in the 325b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) // frame. 326b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) SpdyFrame* ConstructSpdyFrame( 327b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) const SpdyHeaderInfo& header_info, 328b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) scoped_ptr<SpdyHeaderBlock> headers) const; 329b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) 330b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) // Construct a SPDY frame. If it is a SYN_STREAM or SYN_REPLY frame (as 331b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) // specified in header_info.kind), the headers provided in extra_headers and 332b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) // (if non-NULL) tail_headers are concatenated and included in the frame. 333b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) // (extra_headers must always be non-NULL.) 334b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) SpdyFrame* ConstructSpdyFrame(const SpdyHeaderInfo& header_info, 335b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) const char* const extra_headers[], 336b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) int extra_header_count, 337b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) const char* const tail_headers[], 338b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) int tail_header_count) const; 339b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) 34090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Construct a generic SpdyControlFrame. 341868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SpdyFrame* ConstructSpdyControlFrame( 342868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) scoped_ptr<SpdyHeaderBlock> headers, 343868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool compressed, 344868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SpdyStreamId stream_id, 345868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) RequestPriority request_priority, 346868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SpdyFrameType type, 347868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SpdyControlFlags flags, 348868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SpdyStreamId associated_stream_id) const; 349868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 350868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Construct a generic SpdyControlFrame. 35190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // 35290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Warning: extra_header_count is the number of header-value pairs in 35390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // extra_headers (so half the number of elements), but tail_headers_size is 35490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // the actual number of elements (both keys and values) in tail_headers. 35590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // TODO(ttuttle): Fix this inconsistency. 356a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) SpdyFrame* ConstructSpdyControlFrame( 357a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const char* const extra_headers[], 358a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) int extra_header_count, 359a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) bool compressed, 360a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) SpdyStreamId stream_id, 361a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) RequestPriority request_priority, 362a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) SpdyFrameType type, 363a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) SpdyControlFlags flags, 36490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const char* const* tail_headers, 36590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) int tail_headers_size, 366a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) SpdyStreamId associated_stream_id) const; 367a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 368868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Construct an expected SPDY reply string from the given headers. 369868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) std::string ConstructSpdyReplyString(const SpdyHeaderBlock& headers) const; 37090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 37190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Construct an expected SPDY SETTINGS frame. 37290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // |settings| are the settings to set. 37390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Returns the constructed frame. The caller takes ownership of the frame. 37490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) SpdyFrame* ConstructSpdySettings(const SettingsMap& settings) const; 37590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 376cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Constructs an expected SPDY SETTINGS acknowledgement frame, if the protocol 377cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // version is SPDY4 or higher, or an empty placeholder frame otherwise. 378cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) SpdyFrame* ConstructSpdySettingsAck() const; 379cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 38090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Construct a SPDY PING frame. 38190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Returns the constructed frame. The caller takes ownership of the frame. 382a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) SpdyFrame* ConstructSpdyPing(uint32 ping_id, bool is_ack) const; 38390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 38490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Construct a SPDY GOAWAY frame with last_good_stream_id = 0. 38590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Returns the constructed frame. The caller takes ownership of the frame. 38690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) SpdyFrame* ConstructSpdyGoAway() const; 38790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 38890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Construct a SPDY GOAWAY frame with the specified last_good_stream_id. 38990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Returns the constructed frame. The caller takes ownership of the frame. 39090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) SpdyFrame* ConstructSpdyGoAway(SpdyStreamId last_good_stream_id) const; 39190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 392f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) // Construct a SPDY GOAWAY frame with the specified last_good_stream_id, 393f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) // status, and description. Returns the constructed frame. The caller takes 394f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) // ownership of the frame. 395f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) SpdyFrame* ConstructSpdyGoAway(SpdyStreamId last_good_stream_id, 396f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) SpdyGoAwayStatus status, 397f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const std::string& desc) const; 398f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 39990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Construct a SPDY WINDOW_UPDATE frame. 40090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Returns the constructed frame. The caller takes ownership of the frame. 40190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) SpdyFrame* ConstructSpdyWindowUpdate( 40290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) SpdyStreamId stream_id, 40390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) uint32 delta_window_size) const; 40490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 40590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Construct a SPDY RST_STREAM frame. 40690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Returns the constructed frame. The caller takes ownership of the frame. 40790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) SpdyFrame* ConstructSpdyRstStream(SpdyStreamId stream_id, 40890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) SpdyRstStreamStatus status) const; 40990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 41090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Constructs a standard SPDY GET SYN frame, optionally compressed 41146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) // for |url|. 41290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // |extra_headers| are the extra header-value pairs, which typically 41390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // will vary the most between calls. 41490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Returns a SpdyFrame. 41590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) SpdyFrame* ConstructSpdyGet(const char* const url, 41690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bool compressed, 41790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) SpdyStreamId stream_id, 41890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) RequestPriority request_priority) const; 41990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 4207d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) SpdyFrame* ConstructSpdyGetForProxy(const char* const url, 4217d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) bool compressed, 4227d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) SpdyStreamId stream_id, 4237d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) RequestPriority request_priority) const; 4247d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 42590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Constructs a standard SPDY GET SYN frame, optionally compressed. 42690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // |extra_headers| are the extra header-value pairs, which typically 42790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // will vary the most between calls. If |direct| is false, the 42890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // the full url will be used instead of simply the path. 42990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Returns a SpdyFrame. 43090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) SpdyFrame* ConstructSpdyGet(const char* const extra_headers[], 43190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) int extra_header_count, 43290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bool compressed, 43390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) int stream_id, 43490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) RequestPriority request_priority, 43590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bool direct) const; 43690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 43790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Constructs a standard SPDY SYN_STREAM frame for a CONNECT request. 43890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) SpdyFrame* ConstructSpdyConnect(const char* const extra_headers[], 43990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) int extra_header_count, 4403551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) int stream_id, 4413551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) RequestPriority priority) const; 44290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 443868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Constructs a standard SPDY push SYN frame. 444868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // |extra_headers| are the extra header-value pairs, which typically 445868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // will vary the most between calls. 446868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Returns a SpdyFrame. 447868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SpdyFrame* ConstructSpdyPush(const char* const extra_headers[], 448868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int extra_header_count, 449868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int stream_id, 450868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int associated_stream_id, 451868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const char* url); 452868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SpdyFrame* ConstructSpdyPush(const char* const extra_headers[], 453868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int extra_header_count, 454868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int stream_id, 455868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int associated_stream_id, 456868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const char* url, 457868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const char* status, 458868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const char* location); 459868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 4606d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) SpdyFrame* ConstructInitialSpdyPushFrame(scoped_ptr<SpdyHeaderBlock> headers, 4616d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) int stream_id, 4626d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) int associated_stream_id); 4636d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 464868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SpdyFrame* ConstructSpdyPushHeaders(int stream_id, 465868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const char* const extra_headers[], 466868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int extra_header_count); 467868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 468116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Construct a SPDY syn (HEADERS or SYN_STREAM, depending on protocol 469116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // version) carrying exactly the given headers and priority. 470116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch SpdyFrame* ConstructSpdySyn(int stream_id, 471116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch const SpdyHeaderBlock& headers, 472116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch RequestPriority priority, 473116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch bool compressed, 474116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch bool fin) const; 475116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 476116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Construct a SPDY reply (HEADERS or SYN_REPLY, depending on protocol 477116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // version) carrying exactly the given headers, and the default priority 478116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // (or no priority, depending on protocl version). 479116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // The |headers| parameter variant is preferred. 480116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch SpdyFrame* ConstructSpdyReply(int stream_id, const SpdyHeaderBlock& headers); 481116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 482868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Constructs a standard SPDY SYN_REPLY frame to match the SPDY GET. 483868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // |extra_headers| are the extra header-value pairs, which typically 484868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // will vary the most between calls. 485868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Returns a SpdyFrame. 486868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SpdyFrame* ConstructSpdyGetSynReply(const char* const extra_headers[], 487868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int extra_header_count, 488868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int stream_id); 489868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 490868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Constructs a standard SPDY SYN_REPLY frame to match the SPDY GET. 491868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // |extra_headers| are the extra header-value pairs, which typically 492868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // will vary the most between calls. 493868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Returns a SpdyFrame. 494868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SpdyFrame* ConstructSpdyGetSynReplyRedirect(int stream_id); 495868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 496868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Constructs a standard SPDY SYN_REPLY frame with an Internal Server 497868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Error status code. 498868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Returns a SpdyFrame. 499868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SpdyFrame* ConstructSpdySynReplyError(int stream_id); 500868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 501868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Constructs a standard SPDY SYN_REPLY frame with the specified status code. 502868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Returns a SpdyFrame. 503868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SpdyFrame* ConstructSpdySynReplyError(const char* const status, 504868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const char* const* const extra_headers, 505868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int extra_header_count, 506868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int stream_id); 507868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 508868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Constructs a standard SPDY POST SYN frame. 509868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // |extra_headers| are the extra header-value pairs, which typically 510868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // will vary the most between calls. 511868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Returns a SpdyFrame. 512868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SpdyFrame* ConstructSpdyPost(const char* url, 513868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SpdyStreamId stream_id, 514868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int64 content_length, 515868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) RequestPriority priority, 516868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const char* const extra_headers[], 517868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int extra_header_count); 518868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 519868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Constructs a chunked transfer SPDY POST SYN frame. 520868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // |extra_headers| are the extra header-value pairs, which typically 521868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // will vary the most between calls. 522868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Returns a SpdyFrame. 523868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SpdyFrame* ConstructChunkedSpdyPost(const char* const extra_headers[], 524868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int extra_header_count); 525868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 526868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Constructs a standard SPDY SYN_REPLY frame to match the SPDY POST. 527868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // |extra_headers| are the extra header-value pairs, which typically 528868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // will vary the most between calls. 529868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Returns a SpdyFrame. 530868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SpdyFrame* ConstructSpdyPostSynReply(const char* const extra_headers[], 531868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int extra_header_count); 532868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 533868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Constructs a single SPDY data frame with the contents "hello!" 534868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SpdyFrame* ConstructSpdyBodyFrame(int stream_id, 535868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool fin); 536868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 537868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Constructs a single SPDY data frame with the given content. 538868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SpdyFrame* ConstructSpdyBodyFrame(int stream_id, const char* data, 539868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) uint32 len, bool fin); 540868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 541868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Wraps |frame| in the payload of a data frame in stream |stream_id|. 542868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SpdyFrame* ConstructWrappedSpdyFrame(const scoped_ptr<SpdyFrame>& frame, 543868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int stream_id); 544868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 545868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const SpdyHeaderInfo MakeSpdyHeader(SpdyFrameType type); 546868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 547c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // For versions below SPDY4, adds the version HTTP/1.1 header. 548c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch void MaybeAddVersionHeader(SpdyFrameWithNameValueBlockIR* frame_ir) const; 549116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch void MaybeAddVersionHeader(SpdyHeaderBlock* block) const; 550c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch 551c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // Maps |priority| to SPDY version priority, and sets it on |frame_ir|. 552c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch void SetPriority(RequestPriority priority, SpdySynStreamIR* frame_ir) const; 553c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch 55490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) NextProto protocol() const { return protocol_; } 55590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) SpdyMajorVersion spdy_version() const { return spdy_version_; } 55690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bool is_spdy2() const { return protocol_ < kProtoSPDY3; } 557a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch bool include_version_header() const { return protocol_ < kProtoSPDY4; } 558c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch scoped_ptr<SpdyFramer> CreateFramer(bool compressed) const; 55990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 560868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const char* GetMethodKey() const; 561868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const char* GetStatusKey() const; 562868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const char* GetHostKey() const; 563868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const char* GetSchemeKey() const; 564868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const char* GetVersionKey() const; 565868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const char* GetPathKey() const; 566868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 567b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) private: 5687d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // |content_length| may be NULL, in which case the content-length 5697d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // header will be omitted. 5707d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) scoped_ptr<SpdyHeaderBlock> ConstructHeaderBlock( 5717d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) base::StringPiece method, 5727d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) base::StringPiece url, 5737d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) int64* content_length) const; 5747d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 575b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) const NextProto protocol_; 57690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const SpdyMajorVersion spdy_version_; 577b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)}; 578b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) 5792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} // namespace net 5802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif // NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ 582