#include "base/basictypes.h"
#include "base/compiler_specific.h"
-#include "base/file_util.h"
#include "base/files/file_path.h"
+#include "base/files/file_util.h"
#include "base/json/json_writer.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
session_deps_.net_log = log.bound().net_log();
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
for (size_t i = 0; i < data_count; ++i) {
session_deps_.socket_factory->AddSocketDataProvider(data[i]);
DISALLOW_COPY_AND_ASSIGN(BeforeNetworkStartHandler);
};
+class BeforeProxyHeadersSentHandler {
+ public:
+ BeforeProxyHeadersSentHandler()
+ : observed_before_proxy_headers_sent_(false) {}
+
+ void OnBeforeProxyHeadersSent(const ProxyInfo& proxy_info,
+ HttpRequestHeaders* request_headers) {
+ observed_before_proxy_headers_sent_ = true;
+ observed_proxy_server_uri_ = proxy_info.proxy_server().ToURI();
+ }
+
+ bool observed_before_proxy_headers_sent() const {
+ return observed_before_proxy_headers_sent_;
+ }
+
+ std::string observed_proxy_server_uri() const {
+ return observed_proxy_server_uri_;
+ }
+
+ private:
+ bool observed_before_proxy_headers_sent_;
+ std::string observed_proxy_server_uri_;
+
+ DISALLOW_COPY_AND_ASSIGN(BeforeProxyHeadersSentHandler);
+};
+
// Fill |str| with a long header list that consumes >= |size| bytes.
void FillLargeHeadersString(std::string* str, int size) {
const char* row =
CaptureGroupNameHttpProxySocketPool::CaptureGroupNameSocketPool(
HostResolver* host_resolver,
CertVerifier* /* cert_verifier */)
- : HttpProxyClientSocketPool(0, 0, NULL, host_resolver, NULL, NULL, NULL) {}
+ : HttpProxyClientSocketPool(
+ 0, 0, NULL, host_resolver, NULL, NULL, NULL, NULL) {}
template <>
CaptureGroupNameSSLSocketPool::CaptureGroupNameSocketPool(
NULL,
NULL,
NULL,
- NULL) {}
+ false,
+ NULL) {
+}
//-----------------------------------------------------------------------------
TEST_P(HttpNetworkTransactionTest, Basic) {
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
}
TEST_P(HttpNetworkTransactionTest, SimpleGET) {
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
session_deps_.socket_factory->AddSocketDataProvider(&data);
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
+ BeforeProxyHeadersSentHandler proxy_headers_handler;
+ trans->SetBeforeProxyHeadersSentCallback(
+ base::Bind(&BeforeProxyHeadersSentHandler::OnBeforeProxyHeadersSent,
+ base::Unretained(&proxy_headers_handler)));
MockWrite data_writes1[] = {
MockWrite("HEAD / HTTP/1.1\r\n"
EXPECT_EQ(1234, response->headers->GetContentLength());
EXPECT_EQ("HTTP/1.1 404 Not Found", response->headers->GetStatusLine());
EXPECT_TRUE(response->proxy_server.IsEmpty());
+ EXPECT_FALSE(proxy_headers_handler.observed_before_proxy_headers_sent());
std::string server_header;
void* iter = NULL;
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockRead data_reads[] = {
MockRead("HTTP/1.0 100 Continue\r\n\r\n"),
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockRead data_reads[] = {
MockRead("HTTP/1.1 102 Unspecified status code\r\n\r\n"
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockRead data_reads[] = {
MockRead(SYNCHRONOUS, "HTTP/1.0 100 Continue\r\n"),
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
-
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockRead data_reads[] = {
MockRead(ASYNC, 0),
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockRead data_reads[] = {
MockRead(ASYNC, ERR_CONNECTION_RESET),
session_deps_.net_log = &log;
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockWrite data_writes1[] = {
MockWrite("GET / HTTP/1.1\r\n"
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockWrite data_writes[] = {
MockWrite("GET / HTTP/1.1\r\n"
// We are using a DIRECT connection (i.e. no proxy) for this session.
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockWrite data_writes1[] = {
MockWrite("GET / HTTP/1.1\r\n"
spdy_util_.ConstructSpdyWindowUpdate(1, wrapped_get_resp1->size()));
// CONNECT to news.google.com:443 via SPDY.
- SpdySynStreamIR connect2_ir(3);
- spdy_util_.SetPriority(LOWEST, &connect2_ir);
- connect2_ir.SetHeader(spdy_util_.GetMethodKey(), "CONNECT");
- connect2_ir.SetHeader(spdy_util_.GetPathKey(), "news.google.com:443");
- connect2_ir.SetHeader(spdy_util_.GetHostKey(), "news.google.com");
- spdy_util_.MaybeAddVersionHeader(&connect2_ir);
+ SpdyHeaderBlock connect2_block;
+ connect2_block[spdy_util_.GetMethodKey()] = "CONNECT";
+ connect2_block[spdy_util_.GetPathKey()] = "news.google.com:443";
+ connect2_block[spdy_util_.GetHostKey()] = "news.google.com";
+ spdy_util_.MaybeAddVersionHeader(&connect2_block);
scoped_ptr<SpdyFrame> connect2(
- spdy_util_.CreateFramer(false)->SerializeFrame(connect2_ir));
+ spdy_util_.ConstructSpdySyn(3, connect2_block, LOWEST, false, false));
scoped_ptr<SpdyFrame> conn_resp2(
spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3));
// http://www.google.com/
scoped_ptr<SpdyHeaderBlock> headers(
spdy_util_.ConstructGetHeaderBlockForProxy("http://www.google.com/"));
- scoped_ptr<SpdyFrame> get1(spdy_util_.ConstructSpdyControlFrame(
- headers.Pass(), false, 1, LOWEST, SYN_STREAM, CONTROL_FLAG_FIN, 0));
+ scoped_ptr<SpdyFrame> get1(
+ spdy_util_.ConstructSpdySyn(1, *headers, LOWEST, false, true));
scoped_ptr<SpdyFrame> get_resp1(
spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
scoped_ptr<SpdyFrame> body1(
// http://news.google.com/
scoped_ptr<SpdyHeaderBlock> headers2(
spdy_util_.ConstructGetHeaderBlockForProxy("http://news.google.com/"));
- scoped_ptr<SpdyFrame> get2(spdy_util_.ConstructSpdyControlFrame(
- headers2.Pass(), false, 3, LOWEST, SYN_STREAM, CONTROL_FLAG_FIN, 0));
+ scoped_ptr<SpdyFrame> get2(
+ spdy_util_.ConstructSpdySyn(3, *headers2, LOWEST, false, true));
scoped_ptr<SpdyFrame> get_resp2(
spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3));
scoped_ptr<SpdyFrame> body2(
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockWrite data_writes1[] = {
MockWrite("GET http://www.google.com/ HTTP/1.1\r\n"
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
// Respond with 300 kb of headers (we should fail after 256 kb).
std::string large_headers_string;
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
// The password contains an escaped character -- for this test to pass it
// will need to be unescaped by HttpNetworkTransaction.
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockWrite data_writes1[] = {
MockWrite("GET / HTTP/1.1\r\n"
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockWrite data_writes1[] = {
MockWrite("GET / HTTP/1.1\r\n"
// Create a transaction (the dependencies aren't important).
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpNetworkTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
// Setup some state (which we expect ResetStateForRestart() will clear).
trans->read_buf_ = new IOBuffer(15);
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockWrite data_writes[] = {
MockWrite("GET / HTTP/1.1\r\n"
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
int rv = trans->Start(&request, callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
int rv = trans->Start(&request, callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
int rv = trans->Start(&request, callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
int rv = trans->Start(&request, callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
int rv = trans->Start(&request, callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
int rv = trans->Start(&request, callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
// The proxy responds to the connect with a 407, using a persistent
// connection.
+ const char* const kAuthStatus = "407";
const char* const kAuthChallenge[] = {
- spdy_util_.GetStatusKey(), "407 Proxy Authentication Required",
- spdy_util_.GetVersionKey(), "HTTP/1.1",
"proxy-authenticate", "Basic realm=\"MyRealm1\"",
};
-
- scoped_ptr<SpdyFrame> conn_auth_resp(
- spdy_util_.ConstructSpdyControlFrame(NULL,
- 0,
- false,
- 1,
- LOWEST,
- SYN_REPLY,
- CONTROL_FLAG_NONE,
- kAuthChallenge,
- arraysize(kAuthChallenge),
- 0));
+ scoped_ptr<SpdyFrame> conn_auth_resp(spdy_util_.ConstructSpdySynReplyError(
+ kAuthStatus, kAuthChallenge, arraysize(kAuthChallenge) / 2, 1));
scoped_ptr<SpdyFrame> conn_resp(
spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3));
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
int rv = trans->Start(&request, callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockWrite data_writes[] = {
MockWrite("GET / HTTP/1.1\r\n"
session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70"));
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockWrite data_writes[] = {
MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n"
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockWrite data_writes[] = {
MockWrite("GET / HTTP/1.1\r\n"
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockWrite data_writes[] = {
MockWrite("POST / HTTP/1.1\r\n"
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockWrite data_writes[] = {
MockWrite("PUT / HTTP/1.1\r\n"
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockWrite data_writes[] = {
MockWrite("HEAD / HTTP/1.1\r\n"
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockWrite data_writes[] = {
MockWrite("GET / HTTP/1.1\r\n"
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockWrite data_writes[] = {
MockWrite("GET / HTTP/1.1\r\n"
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockWrite data_writes[] = {
MockWrite("GET / HTTP/1.1\r\n"
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockWrite data_writes[] = {
MockWrite("GET / HTTP/1.1\r\n"
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
char write_buffer[] = { 0x04, 0x01, 0x00, 0x50, 127, 0, 0, 1, 0 };
char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 };
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
unsigned char write_buffer[] = { 0x04, 0x01, 0x01, 0xBB, 127, 0, 0, 1, 0 };
unsigned char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 };
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
char write_buffer[] = { 0x04, 0x01, 0x00, 0x50, 127, 0, 0, 1, 0 };
char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 };
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 };
const char kSOCKS5GreetResponse[] = { 0x05, 0x00 };
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 };
const char kSOCKS5GreetResponse[] = { 0x05, 0x00 };
session->http_server_properties();
http_server_properties->SetAlternateProtocol(
HostPortPair("host.with.alternate", 80), 443,
- AlternateProtocolFromNextProto(next_proto));
+ AlternateProtocolFromNextProto(next_proto), 1);
return session;
}
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
TestCompletionCallback callback;
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
// Warm up the host cache so it has an entry for "www.google.com".
AddressList addrlist;
TestCompletionCallback callback;
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
int rv = trans->Start(&request, callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
TestCompletionCallback callback;
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
int rv = trans->Start(&request, callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
int rv = trans->Start(&request, callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockRead data_reads[] = {
MockRead("HTTP/1.0 200 OK\r\nContent-Length:6719476739\r\n\r\n"),
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockRead data_reads[] = {
MockRead("HTTP/1.0 200 OK\r\n\r\n"),
std::string temp_file_content("Unreadable file.");
ASSERT_TRUE(base::WriteFile(temp_file, temp_file_content.c_str(),
temp_file_content.length()));
- ASSERT_TRUE(file_util::MakeFileUnreadable(temp_file));
+ ASSERT_TRUE(base::MakeFileUnreadable(temp_file));
ScopedVector<UploadElementReader> element_readers;
element_readers.push_back(
// If we try to upload an unreadable file, the transaction should fail.
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
StaticSocketDataProvider data(NULL, 0, NULL, 0);
session_deps_.socket_factory->AddSocketDataProvider(&data);
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
StaticSocketDataProvider data;
session_deps_.socket_factory->AddSocketDataProvider(&data);
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
// Issue the first request with Authorize headers. There should be a
// password prompt for first_realm waiting to be filled in after the
EXPECT_EQ("hello world", response_data);
ASSERT_TRUE(http_server_properties.HasAlternateProtocol(http_host_port_pair));
- const PortAlternateProtocolPair alternate =
+ const AlternateProtocolInfo alternate =
http_server_properties.GetAlternateProtocol(http_host_port_pair);
- PortAlternateProtocolPair expected_alternate;
- expected_alternate.port = 443;
- expected_alternate.protocol = AlternateProtocolFromNextProto(GetParam());
+ AlternateProtocolInfo expected_alternate(
+ 443, AlternateProtocolFromNextProto(GetParam()), 1);
EXPECT_TRUE(expected_alternate.Equals(alternate));
}
http_server_properties->SetAlternateProtocol(
HostPortPair::FromURL(request.url),
666 /* port is ignored by MockConnect anyway */,
- AlternateProtocolFromNextProto(GetParam()));
+ AlternateProtocolFromNextProto(GetParam()), 1);
scoped_ptr<HttpTransaction> trans(
new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
ASSERT_TRUE(http_server_properties->HasAlternateProtocol(
HostPortPair::FromURL(request.url)));
- const PortAlternateProtocolPair alternate =
+ const AlternateProtocolInfo alternate =
http_server_properties->GetAlternateProtocol(
HostPortPair::FromURL(request.url));
EXPECT_EQ(ALTERNATE_PROTOCOL_BROKEN, alternate.protocol);
http_server_properties->SetAlternateProtocol(
HostPortPair::FromURL(restricted_port_request.url),
kUnrestrictedAlternatePort,
- AlternateProtocolFromNextProto(GetParam()));
+ AlternateProtocolFromNextProto(GetParam()), 1);
scoped_ptr<HttpTransaction> trans(
new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
http_server_properties->SetAlternateProtocol(
HostPortPair::FromURL(restricted_port_request.url),
kUnrestrictedAlternatePort,
- AlternateProtocolFromNextProto(GetParam()));
+ AlternateProtocolFromNextProto(GetParam()), 1);
scoped_ptr<HttpTransaction> trans(
new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
http_server_properties->SetAlternateProtocol(
HostPortPair::FromURL(restricted_port_request.url),
kRestrictedAlternatePort,
- AlternateProtocolFromNextProto(GetParam()));
+ AlternateProtocolFromNextProto(GetParam()), 1);
scoped_ptr<HttpTransaction> trans(
new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
http_server_properties->SetAlternateProtocol(
HostPortPair::FromURL(unrestricted_port_request.url),
kRestrictedAlternatePort,
- AlternateProtocolFromNextProto(GetParam()));
+ AlternateProtocolFromNextProto(GetParam()), 1);
scoped_ptr<HttpTransaction> trans(
new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
http_server_properties->SetAlternateProtocol(
HostPortPair::FromURL(unrestricted_port_request.url),
kUnrestrictedAlternatePort,
- AlternateProtocolFromNextProto(GetParam()));
+ AlternateProtocolFromNextProto(GetParam()), 1);
scoped_ptr<HttpTransaction> trans(
new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
http_server_properties->SetAlternateProtocol(
HostPortPair::FromURL(request.url),
kUnsafePort,
- AlternateProtocolFromNextProto(GetParam()));
+ AlternateProtocolFromNextProto(GetParam()), 1);
scoped_ptr<HttpTransaction> trans(
new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
request.load_flags = 0;
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
- HttpNetworkTransaction trans(DEFAULT_PRIORITY, session);
+ HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
for (int round = 0; round < test_config.num_auth_rounds; ++round) {
const TestRound& read_write_round = test_config.rounds[round];
session_deps_.host_resolver->set_synchronous_mode(true);
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
data.set_connect_data(mock_connect);
request.url = GURL("http://www.google.com/");
request.load_flags = 0;
- HttpNetworkTransaction trans(DEFAULT_PRIORITY, session);
+ HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
TestCompletionCallback callback;
int rv = trans.Start(&request, callback.callback(), BoundNetLog());
base::MessageLoop::current()->RunUntilIdle();
// Socket should now be idle, waiting to be reused.
- EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session));
+ EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session.get()));
}
// Test a basic GET request through a proxy.
scoped_ptr<HttpTransaction> trans(
new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
+ BeforeProxyHeadersSentHandler proxy_headers_handler;
+ trans->SetBeforeProxyHeadersSentCallback(
+ base::Bind(&BeforeProxyHeadersSentHandler::OnBeforeProxyHeadersSent,
+ base::Unretained(&proxy_headers_handler)));
int rv = trans->Start(&request, callback1.callback(), log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_TRUE(response->was_fetched_via_proxy);
EXPECT_TRUE(
response->proxy_server.Equals(HostPortPair::FromString("myproxy:70")));
+ EXPECT_TRUE(proxy_headers_handler.observed_before_proxy_headers_sent());
+ EXPECT_EQ("myproxy:70", proxy_headers_handler.observed_proxy_server_uri());
EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion());
LoadTimingInfo load_timing_info;
spdy_util_.ConstructWrappedSpdyFrame(req1, 1));
// SPDY GET for HTTP URL (through the proxy, but not the tunnel).
- SpdySynStreamIR req2_ir(3);
- spdy_util_.SetPriority(MEDIUM, &req2_ir);
- req2_ir.set_fin(true);
- req2_ir.SetHeader(spdy_util_.GetMethodKey(), "GET");
- req2_ir.SetHeader(spdy_util_.GetPathKey(),
- spdy_util_.is_spdy2() ? http_url.c_str() : "/");
- req2_ir.SetHeader(spdy_util_.GetHostKey(), "www.google.com:443");
- req2_ir.SetHeader(spdy_util_.GetSchemeKey(), "http");
- spdy_util_.MaybeAddVersionHeader(&req2_ir);
+ SpdyHeaderBlock req2_block;
+ req2_block[spdy_util_.GetMethodKey()] = "GET";
+ req2_block[spdy_util_.GetPathKey()] =
+ spdy_util_.is_spdy2() ? http_url.c_str() : "/";
+ req2_block[spdy_util_.GetHostKey()] = "www.google.com:443";
+ req2_block[spdy_util_.GetSchemeKey()] = "http";
+ spdy_util_.MaybeAddVersionHeader(&req2_block);
scoped_ptr<SpdyFrame> req2(
- spdy_util_.CreateFramer(false)->SerializeFrame(req2_ir));
+ spdy_util_.ConstructSpdySyn(3, req2_block, MEDIUM, false, true));
MockWrite writes1[] = {
CreateMockWrite(*connect, 0),
// SPDY GET for HTTP URL (through SPDY proxy)
scoped_ptr<SpdyHeaderBlock> headers(
spdy_util_.ConstructGetHeaderBlockForProxy("http://www.google.com/"));
- scoped_ptr<SpdyFrame> req1(spdy_util_.ConstructSpdyControlFrame(
- headers.Pass(), false, 1, LOWEST, SYN_STREAM, CONTROL_FLAG_FIN, 0));
+ scoped_ptr<SpdyFrame> req1(
+ spdy_util_.ConstructSpdySyn(1, *headers, LOWEST, false, true));
MockWrite writes1[] = {
CreateMockWrite(*req1, 0),
base::FilePath certs_dir = GetTestCertsDirectory();
scoped_refptr<X509Certificate> server_cert(
ImportCertFromFile(certs_dir, "ok_cert.pem"));
- ASSERT_NE(static_cast<X509Certificate*>(NULL), server_cert);
+ ASSERT_NE(static_cast<X509Certificate*>(NULL), server_cert.get());
SSLSocketDataProvider ssl1(ASYNC, OK); // to the proxy
ssl1.SetNextProto(GetParam());
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockConnect mock_connect(SYNCHRONOUS, ERR_CONNECTION_REFUSED);
StaticSocketDataProvider data;
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED);
StaticSocketDataProvider data;
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockWrite data_writes[] = {
MockWrite(SYNCHRONOUS, ERR_CONNECTION_RESET),
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockWrite data_writes[] = {
MockWrite(ASYNC, ERR_CONNECTION_RESET),
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockWrite data_writes[] = {
MockWrite("GET / HTTP/1.1\r\n"
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockWrite data_writes[] = {
MockWrite("GET / HTTP/1.1\r\n"
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockWrite data_writes[] = {
MockWrite("GET / HTTP/1.1\r\n"
FakeStreamFactory* fake_factory = new FakeStreamFactory();
peer.SetHttpStreamFactory(scoped_ptr<HttpStreamFactory>(fake_factory));
- HttpNetworkTransaction trans(LOW, session);
+ HttpNetworkTransaction trans(LOW, session.get());
ASSERT_TRUE(fake_factory->last_stream_request() == NULL);
FakeStreamFactory* fake_factory = new FakeStreamFactory();
peer.SetHttpStreamFactory(scoped_ptr<HttpStreamFactory>(fake_factory));
- HttpNetworkTransaction trans(LOW, session);
+ HttpNetworkTransaction trans(LOW, session.get());
HttpRequestInfo request;
TestCompletionCallback callback;
FakeStreamFactory* fake_factory = new FakeStreamFactory();
peer.SetHttpStreamFactory(scoped_ptr<HttpStreamFactory>(fake_factory));
- HttpNetworkTransaction trans(LOW, session);
+ HttpNetworkTransaction trans(LOW, session.get());
HttpRequestInfo request;
TestCompletionCallback callback;
peer.SetHttpStreamFactoryForWebSocket(
scoped_ptr<HttpStreamFactory>(fake_factory));
- HttpNetworkTransaction trans(LOW, session);
+ HttpNetworkTransaction trans(LOW, session.get());
trans.SetWebSocketHandshakeStreamCreateHelper(
&websocket_stream_create_helper);
ASSERT_EQ(ERR_IO_PENDING,
http_trans->Start(&http_request, http_callback.callback(),
BoundNetLog()));
- EXPECT_TRUE(IsTransportSocketPoolStalled(session));
+ EXPECT_TRUE(IsTransportSocketPoolStalled(session.get()));
// Wait for response from SSL request.
ASSERT_EQ(OK, ssl_callback.WaitForResult());
// The SSL socket should automatically be closed, so the HTTP request can
// start.
- EXPECT_EQ(0, GetIdleSocketCountInSSLSocketPool(session));
- ASSERT_FALSE(IsTransportSocketPoolStalled(session));
+ EXPECT_EQ(0, GetIdleSocketCountInSSLSocketPool(session.get()));
+ ASSERT_FALSE(IsTransportSocketPoolStalled(session.get()));
// The HTTP request can now complete.
ASSERT_EQ(OK, http_callback.WaitForResult());
ASSERT_EQ(OK, ReadTransaction(http_trans.get(), &response_data));
EXPECT_EQ("falafel", response_data);
- EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session));
+ EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session.get()));
}
// Tests that when a SSL connection is established but there's no corresponding
session->ssl_config_service()->GetSSLConfig(&ssl_config);
http_stream_factory->PreconnectStreams(1, ssl_request, DEFAULT_PRIORITY,
ssl_config, ssl_config);
- EXPECT_EQ(0, GetIdleSocketCountInSSLSocketPool(session));
+ EXPECT_EQ(0, GetIdleSocketCountInSSLSocketPool(session.get()));
// Start the HTTP request. Pool should stall.
TestCompletionCallback http_callback;
ASSERT_EQ(ERR_IO_PENDING,
http_trans->Start(&http_request, http_callback.callback(),
BoundNetLog()));
- EXPECT_TRUE(IsTransportSocketPoolStalled(session));
+ EXPECT_TRUE(IsTransportSocketPoolStalled(session.get()));
// The SSL connection will automatically be closed once the connection is
// established, to let the HTTP request start.
ASSERT_EQ(OK, ReadTransaction(http_trans.get(), &response_data));
EXPECT_EQ("falafel", response_data);
- EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session));
+ EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session.get()));
}
TEST_P(HttpNetworkTransactionTest, PostReadsErrorResponseAfterReset) {
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
// Send headers successfully, but get an error while sending the body.
MockWrite data_writes[] = {
MockWrite("POST / HTTP/1.1\r\n"
request1.load_flags = 0;
scoped_ptr<HttpTransaction> trans1(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
int rv = trans1->Start(&request1, callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
request2.load_flags = 0;
scoped_ptr<HttpTransaction> trans2(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
rv = trans2->Start(&request2, callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
// Send headers successfully, but get an error while sending the body.
MockWrite data_writes[] = {
MockWrite("POST / HTTP/1.1\r\n"
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
// Send headers successfully, but get an error while sending the body.
MockWrite data_writes[] = {
MockWrite("POST / HTTP/1.1\r\n"
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
MockWrite data_writes[] = {
MockWrite("POST / HTTP/1.1\r\n"
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
// Send headers successfully, but get an error while sending the body.
MockWrite data_writes[] = {
MockWrite("POST / HTTP/1.1\r\n"
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
// Send headers successfully, but get an error while sending the body.
MockWrite data_writes[] = {
MockWrite("POST / HTTP/1.1\r\n"
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
// Send headers successfully, but get an error while sending the body.
MockWrite data_writes[] = {
MockWrite("POST / HTTP/1.1\r\n"
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
- new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
+ new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
// Send headers successfully, but get an error while sending the body.
MockWrite data_writes[] = {
MockWrite("POST / HTTP/1.1\r\n"