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

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

Issue 10448083: Fix out of order SYN_STEAM frames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix willchan's comments Created 8 years, 5 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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 EXPECT_EQ(OK, connection->Init(host_port_pair.ToString(), transport_params, 270 EXPECT_EQ(OK, connection->Init(host_port_pair.ToString(), transport_params,
271 LOWEST, CompletionCallback(), 271 LOWEST, CompletionCallback(),
272 session_->GetTransportSocketPool( 272 session_->GetTransportSocketPool(
273 HttpNetworkSession::NORMAL_SOCKET_POOL), 273 HttpNetworkSession::NORMAL_SOCKET_POOL),
274 BoundNetLog())); 274 BoundNetLog()));
275 spdy_session->InitializeWithSocket(connection.release(), false, OK); 275 spdy_session->InitializeWithSocket(connection.release(), false, OK);
276 BoundNetLog net_log; 276 BoundNetLog net_log;
277 277
278 // Conjure up a stream. 278 // Conjure up a stream.
279 scoped_refptr<SpdyStream> stream = new SpdyStream(spdy_session, 279 scoped_refptr<SpdyStream> stream = new SpdyStream(spdy_session,
280 2,
281 true, 280 true,
282 net_log); 281 net_log);
282 stream->set_stream_id(2);
283 EXPECT_FALSE(stream->response_received()); 283 EXPECT_FALSE(stream->response_received());
284 EXPECT_FALSE(stream->HasUrl()); 284 EXPECT_FALSE(stream->HasUrl());
285 285
286 // Set a couple of headers. 286 // Set a couple of headers.
287 SpdyHeaderBlock response; 287 SpdyHeaderBlock response;
288 response["url"] = kStreamUrl; 288 response["url"] = kStreamUrl;
289 stream->OnResponseReceived(response); 289 stream->OnResponseReceived(response);
290 290
291 // Send some basic headers. 291 // Send some basic headers.
292 SpdyHeaderBlock headers; 292 SpdyHeaderBlock headers;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 (*headers)["scheme"] = url.scheme(); 401 (*headers)["scheme"] = url.scheme();
402 (*headers)["host"] = url.host(); 402 (*headers)["host"] = url.host();
403 (*headers)["url"] = url.path(); 403 (*headers)["url"] = url.path();
404 (*headers)["version"] = "HTTP/1.1"; 404 (*headers)["version"] = "HTTP/1.1";
405 stream->set_spdy_headers(headers); 405 stream->set_spdy_headers(headers);
406 EXPECT_TRUE(stream->HasUrl()); 406 EXPECT_TRUE(stream->HasUrl());
407 EXPECT_EQ(kStreamUrl, stream->GetUrl().spec()); 407 EXPECT_EQ(kStreamUrl, stream->GetUrl().spec());
408 408
409 EXPECT_EQ(ERR_IO_PENDING, stream->SendRequest(true)); 409 EXPECT_EQ(ERR_IO_PENDING, stream->SendRequest(true));
410 410
411 EXPECT_EQ(OK, callback.WaitForResult());
412
411 const SpdyStreamId stream_id = stream->stream_id(); 413 const SpdyStreamId stream_id = stream->stream_id();
412 414
413 EXPECT_EQ(OK, callback.WaitForResult());
414
415 EXPECT_TRUE(delegate->send_headers_completed()); 415 EXPECT_TRUE(delegate->send_headers_completed());
416 EXPECT_EQ("200", (*delegate->response())["status"]); 416 EXPECT_EQ("200", (*delegate->response())["status"]);
417 EXPECT_EQ("HTTP/1.1", (*delegate->response())["version"]); 417 EXPECT_EQ("HTTP/1.1", (*delegate->response())["version"]);
418 EXPECT_EQ(std::string("\0hello!\xff", 8), delegate->received_data()); 418 EXPECT_EQ(std::string("\0hello!\xff", 8), delegate->received_data());
419 EXPECT_EQ(8, delegate->data_sent()); 419 EXPECT_EQ(8, delegate->data_sent());
420 EXPECT_TRUE(delegate->closed()); 420 EXPECT_TRUE(delegate->closed());
421 421
422 // Check that the NetLog was filled reasonably. 422 // Check that the NetLog was filled reasonably.
423 net::CapturingNetLog::CapturedEntryList entries; 423 net::CapturingNetLog::CapturedEntryList entries;
424 log.GetEntries(&entries); 424 log.GetEntries(&entries);
425 EXPECT_LT(0u, entries.size()); 425 EXPECT_LT(0u, entries.size());
426 426
427 // Check that we logged SPDY_STREAM_ERROR correctly. 427 // Check that we logged SPDY_STREAM_ERROR correctly.
428 int pos = net::ExpectLogContainsSomewhere( 428 int pos = net::ExpectLogContainsSomewhere(
429 entries, 0, 429 entries, 0,
430 net::NetLog::TYPE_SPDY_STREAM_ERROR, 430 net::NetLog::TYPE_SPDY_STREAM_ERROR,
431 net::NetLog::PHASE_NONE); 431 net::NetLog::PHASE_NONE);
432 432
433 int stream_id2; 433 int stream_id2;
434 ASSERT_TRUE(entries[pos].GetIntegerValue("stream_id", &stream_id2)); 434 ASSERT_TRUE(entries[pos].GetIntegerValue("stream_id", &stream_id2));
435 EXPECT_EQ(static_cast<int>(stream_id), stream_id2); 435 EXPECT_EQ(static_cast<int>(stream_id), stream_id2);
436 } 436 }
437 437
438 } // namespace net 438 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698