Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: net/spdy/spdy_stream_spdy3_unittest.cc

Issue 10448083: Fix out of order SYN_STEAM frames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address willchan's comments. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 EXPECT_EQ(OK, connection->Init(host_port_pair.ToString(), transport_params, 268 EXPECT_EQ(OK, connection->Init(host_port_pair.ToString(), transport_params,
269 LOWEST, CompletionCallback(), 269 LOWEST, CompletionCallback(),
270 session_->GetTransportSocketPool( 270 session_->GetTransportSocketPool(
271 HttpNetworkSession::NORMAL_SOCKET_POOL), 271 HttpNetworkSession::NORMAL_SOCKET_POOL),
272 BoundNetLog())); 272 BoundNetLog()));
273 spdy_session->InitializeWithSocket(connection.release(), false, OK); 273 spdy_session->InitializeWithSocket(connection.release(), false, OK);
274 BoundNetLog net_log; 274 BoundNetLog net_log;
275 275
276 // Conjure up a stream. 276 // Conjure up a stream.
277 scoped_refptr<SpdyStream> stream = new SpdyStream(spdy_session, 277 scoped_refptr<SpdyStream> stream = new SpdyStream(spdy_session,
278 2,
279 true, 278 true,
280 net_log); 279 net_log);
280 stream->set_stream_id(2);
281 EXPECT_FALSE(stream->response_received()); 281 EXPECT_FALSE(stream->response_received());
282 EXPECT_FALSE(stream->HasUrl()); 282 EXPECT_FALSE(stream->HasUrl());
283 283
284 // Set a couple of headers. 284 // Set a couple of headers.
285 SpdyHeaderBlock response; 285 SpdyHeaderBlock response;
286 GURL url(kStreamUrl); 286 GURL url(kStreamUrl);
287 response[":host"] = url.host(); 287 response[":host"] = url.host();
288 response[":scheme"] = url.scheme(); 288 response[":scheme"] = url.scheme();
289 response[":path"] = url.path(); 289 response[":path"] = url.path();
290 stream->OnResponseReceived(response); 290 stream->OnResponseReceived(response);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 (*headers)[":scheme"] = url.scheme(); 402 (*headers)[":scheme"] = url.scheme();
403 (*headers)[":host"] = url.host(); 403 (*headers)[":host"] = url.host();
404 (*headers)[":path"] = url.path(); 404 (*headers)[":path"] = url.path();
405 (*headers)[":version"] = "HTTP/1.1"; 405 (*headers)[":version"] = "HTTP/1.1";
406 stream->set_spdy_headers(headers); 406 stream->set_spdy_headers(headers);
407 EXPECT_TRUE(stream->HasUrl()); 407 EXPECT_TRUE(stream->HasUrl());
408 EXPECT_EQ(kStreamUrl, stream->GetUrl().spec()); 408 EXPECT_EQ(kStreamUrl, stream->GetUrl().spec());
409 409
410 EXPECT_EQ(ERR_IO_PENDING, stream->SendRequest(true)); 410 EXPECT_EQ(ERR_IO_PENDING, stream->SendRequest(true));
411 411
412 EXPECT_EQ(OK, callback.WaitForResult());
413
412 const SpdyStreamId stream_id = stream->stream_id(); 414 const SpdyStreamId stream_id = stream->stream_id();
413 415
414 EXPECT_EQ(OK, callback.WaitForResult());
415
416 EXPECT_TRUE(delegate->send_headers_completed()); 416 EXPECT_TRUE(delegate->send_headers_completed());
417 EXPECT_EQ("200", (*delegate->response())[":status"]); 417 EXPECT_EQ("200", (*delegate->response())[":status"]);
418 EXPECT_EQ("HTTP/1.1", (*delegate->response())[":version"]); 418 EXPECT_EQ("HTTP/1.1", (*delegate->response())[":version"]);
419 EXPECT_EQ(std::string("\0hello!\xff", 8), delegate->received_data()); 419 EXPECT_EQ(std::string("\0hello!\xff", 8), delegate->received_data());
420 EXPECT_EQ(8, delegate->data_sent()); 420 EXPECT_EQ(8, delegate->data_sent());
421 EXPECT_TRUE(delegate->closed()); 421 EXPECT_TRUE(delegate->closed());
422 422
423 // Check that the NetLog was filled reasonably. 423 // Check that the NetLog was filled reasonably.
424 net::CapturingNetLog::EntryList entries; 424 net::CapturingNetLog::EntryList entries;
425 log.GetEntries(&entries); 425 log.GetEntries(&entries);
426 EXPECT_LT(0u, entries.size()); 426 EXPECT_LT(0u, entries.size());
427 427
428 // Check that we logged SPDY_STREAM_ERROR correctly. 428 // Check that we logged SPDY_STREAM_ERROR correctly.
429 int pos = net::ExpectLogContainsSomewhere( 429 int pos = net::ExpectLogContainsSomewhere(
430 entries, 0, 430 entries, 0,
431 net::NetLog::TYPE_SPDY_STREAM_ERROR, 431 net::NetLog::TYPE_SPDY_STREAM_ERROR,
432 net::NetLog::PHASE_NONE); 432 net::NetLog::PHASE_NONE);
433 433
434 CapturingNetLog::Entry entry = entries[pos]; 434 CapturingNetLog::Entry entry = entries[pos];
435 NetLogSpdyStreamErrorParameter* request_params = 435 NetLogSpdyStreamErrorParameter* request_params =
436 static_cast<NetLogSpdyStreamErrorParameter*>( 436 static_cast<NetLogSpdyStreamErrorParameter*>(
437 entry.extra_parameters.get()); 437 entry.extra_parameters.get());
438 EXPECT_EQ(stream_id, request_params->stream_id()); 438 EXPECT_EQ(stream_id, request_params->stream_id());
439 } 439 }
440 440
441 } // namespace net 441 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698