OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "net/base/completion_callback.h" | 6 #include "net/base/completion_callback.h" |
7 #include "net/base/net_log_unittest.h" | 7 #include "net/base/net_log_unittest.h" |
8 #include "net/spdy/buffered_spdy_framer.h" | 8 #include "net/spdy/buffered_spdy_framer.h" |
9 #include "net/spdy/spdy_stream.h" | 9 #include "net/spdy/spdy_stream.h" |
10 #include "net/spdy/spdy_http_utils.h" | 10 #include "net/spdy/spdy_http_utils.h" |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 EXPECT_EQ(OK, connection->Init(host_port_pair.ToString(), transport_params, | 267 EXPECT_EQ(OK, connection->Init(host_port_pair.ToString(), transport_params, |
268 LOWEST, CompletionCallback(), | 268 LOWEST, CompletionCallback(), |
269 session_->GetTransportSocketPool( | 269 session_->GetTransportSocketPool( |
270 HttpNetworkSession::NORMAL_SOCKET_POOL), | 270 HttpNetworkSession::NORMAL_SOCKET_POOL), |
271 BoundNetLog())); | 271 BoundNetLog())); |
272 spdy_session->InitializeWithSocket(connection.release(), false, OK); | 272 spdy_session->InitializeWithSocket(connection.release(), false, OK); |
273 BoundNetLog net_log; | 273 BoundNetLog net_log; |
274 | 274 |
275 // Conjure up a stream. | 275 // Conjure up a stream. |
276 scoped_refptr<SpdyStream> stream = new SpdyStream(spdy_session, | 276 scoped_refptr<SpdyStream> stream = new SpdyStream(spdy_session, |
277 2, | |
278 true, | 277 true, |
279 net_log); | 278 net_log); |
| 279 stream->set_stream_id(2); |
280 EXPECT_FALSE(stream->response_received()); | 280 EXPECT_FALSE(stream->response_received()); |
281 EXPECT_FALSE(stream->HasUrl()); | 281 EXPECT_FALSE(stream->HasUrl()); |
282 | 282 |
283 // Set a couple of headers. | 283 // Set a couple of headers. |
284 SpdyHeaderBlock response; | 284 SpdyHeaderBlock response; |
285 response["url"] = kStreamUrl; | 285 response["url"] = kStreamUrl; |
286 stream->OnResponseReceived(response); | 286 stream->OnResponseReceived(response); |
287 | 287 |
288 // Send some basic headers. | 288 // Send some basic headers. |
289 SpdyHeaderBlock headers; | 289 SpdyHeaderBlock headers; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 (*headers)["scheme"] = url.scheme(); | 397 (*headers)["scheme"] = url.scheme(); |
398 (*headers)["host"] = url.host(); | 398 (*headers)["host"] = url.host(); |
399 (*headers)["url"] = url.path(); | 399 (*headers)["url"] = url.path(); |
400 (*headers)["version"] = "HTTP/1.1"; | 400 (*headers)["version"] = "HTTP/1.1"; |
401 stream->set_spdy_headers(headers); | 401 stream->set_spdy_headers(headers); |
402 EXPECT_TRUE(stream->HasUrl()); | 402 EXPECT_TRUE(stream->HasUrl()); |
403 EXPECT_EQ(kStreamUrl, stream->GetUrl().spec()); | 403 EXPECT_EQ(kStreamUrl, stream->GetUrl().spec()); |
404 | 404 |
405 EXPECT_EQ(ERR_IO_PENDING, stream->SendRequest(true)); | 405 EXPECT_EQ(ERR_IO_PENDING, stream->SendRequest(true)); |
406 | 406 |
| 407 EXPECT_EQ(OK, callback.WaitForResult()); |
| 408 |
407 const SpdyStreamId stream_id = stream->stream_id(); | 409 const SpdyStreamId stream_id = stream->stream_id(); |
408 | 410 |
409 EXPECT_EQ(OK, callback.WaitForResult()); | |
410 | |
411 EXPECT_TRUE(delegate->send_headers_completed()); | 411 EXPECT_TRUE(delegate->send_headers_completed()); |
412 EXPECT_EQ("200", (*delegate->response())["status"]); | 412 EXPECT_EQ("200", (*delegate->response())["status"]); |
413 EXPECT_EQ("HTTP/1.1", (*delegate->response())["version"]); | 413 EXPECT_EQ("HTTP/1.1", (*delegate->response())["version"]); |
414 EXPECT_EQ(std::string("\0hello!\xff", 8), delegate->received_data()); | 414 EXPECT_EQ(std::string("\0hello!\xff", 8), delegate->received_data()); |
415 EXPECT_EQ(8, delegate->data_sent()); | 415 EXPECT_EQ(8, delegate->data_sent()); |
416 EXPECT_TRUE(delegate->closed()); | 416 EXPECT_TRUE(delegate->closed()); |
417 | 417 |
418 // Check that the NetLog was filled reasonably. | 418 // Check that the NetLog was filled reasonably. |
419 net::CapturingNetLog::EntryList entries; | 419 net::CapturingNetLog::EntryList entries; |
420 log.GetEntries(&entries); | 420 log.GetEntries(&entries); |
421 EXPECT_LT(0u, entries.size()); | 421 EXPECT_LT(0u, entries.size()); |
422 | 422 |
423 // Check that we logged SPDY_STREAM_ERROR correctly. | 423 // Check that we logged SPDY_STREAM_ERROR correctly. |
424 int pos = net::ExpectLogContainsSomewhere( | 424 int pos = net::ExpectLogContainsSomewhere( |
425 entries, 0, | 425 entries, 0, |
426 net::NetLog::TYPE_SPDY_STREAM_ERROR, | 426 net::NetLog::TYPE_SPDY_STREAM_ERROR, |
427 net::NetLog::PHASE_NONE); | 427 net::NetLog::PHASE_NONE); |
428 | 428 |
429 CapturingNetLog::Entry entry = entries[pos]; | 429 CapturingNetLog::Entry entry = entries[pos]; |
430 NetLogSpdyStreamErrorParameter* request_params = | 430 NetLogSpdyStreamErrorParameter* request_params = |
431 static_cast<NetLogSpdyStreamErrorParameter*>( | 431 static_cast<NetLogSpdyStreamErrorParameter*>( |
432 entry.extra_parameters.get()); | 432 entry.extra_parameters.get()); |
433 EXPECT_EQ(stream_id, request_params->stream_id()); | 433 EXPECT_EQ(stream_id, request_params->stream_id()); |
434 } | 434 } |
435 | 435 |
436 } // namespace net | 436 } // namespace net |
OLD | NEW |