OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "net/http/bidirectional_stream.h" | 5 #include "net/http/bidirectional_stream.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 TestDelegateBase delegate(nullptr, 0); | 383 TestDelegateBase delegate(nullptr, 0); |
384 HttpNetworkSession::Params params = | 384 HttpNetworkSession::Params params = |
385 SpdySessionDependencies::CreateSessionParams(&session_deps_); | 385 SpdySessionDependencies::CreateSessionParams(&session_deps_); |
386 std::unique_ptr<HttpNetworkSession> session(new HttpNetworkSession(params)); | 386 std::unique_ptr<HttpNetworkSession> session(new HttpNetworkSession(params)); |
387 delegate.SetRunUntilCompletion(true); | 387 delegate.SetRunUntilCompletion(true); |
388 delegate.Start(std::move(request_info), session.get()); | 388 delegate.Start(std::move(request_info), session.get()); |
389 | 389 |
390 EXPECT_EQ(ERR_DISALLOWED_URL_SCHEME, delegate.error()); | 390 EXPECT_EQ(ERR_DISALLOWED_URL_SCHEME, delegate.error()); |
391 } | 391 } |
392 | 392 |
| 393 // Creates a BidirectionalStream with an insecure scheme. Destroy the stream |
| 394 // without waiting for the OnFailed task to be executed. |
| 395 TEST_F(BidirectionalStreamTest, |
| 396 CreateInsecureStreamAndDestroyStreamRightAfter) { |
| 397 std::unique_ptr<BidirectionalStreamRequestInfo> request_info( |
| 398 new BidirectionalStreamRequestInfo); |
| 399 request_info->method = "GET"; |
| 400 request_info->url = GURL("http://www.example.org/"); |
| 401 |
| 402 std::unique_ptr<TestDelegateBase> delegate(new TestDelegateBase(nullptr, 0)); |
| 403 HttpNetworkSession::Params params = |
| 404 SpdySessionDependencies::CreateSessionParams(&session_deps_); |
| 405 std::unique_ptr<HttpNetworkSession> session(new HttpNetworkSession(params)); |
| 406 delegate->Start(std::move(request_info), session.get()); |
| 407 // Reset stream right before the OnFailed task is executed. |
| 408 delegate.reset(); |
| 409 |
| 410 base::RunLoop().RunUntilIdle(); |
| 411 } |
| 412 |
393 // Simulates user calling ReadData after END_STREAM has been received in | 413 // Simulates user calling ReadData after END_STREAM has been received in |
394 // BidirectionalStreamSpdyImpl. | 414 // BidirectionalStreamSpdyImpl. |
395 TEST_F(BidirectionalStreamTest, TestReadDataAfterClose) { | 415 TEST_F(BidirectionalStreamTest, TestReadDataAfterClose) { |
396 std::unique_ptr<SpdySerializedFrame> req( | 416 std::unique_ptr<SpdySerializedFrame> req( |
397 spdy_util_.ConstructSpdyGet("https://www.example.org", 1, LOWEST)); | 417 spdy_util_.ConstructSpdyGet("https://www.example.org", 1, LOWEST)); |
398 // Empty DATA frame with an END_STREAM flag. | 418 // Empty DATA frame with an END_STREAM flag. |
399 std::unique_ptr<SpdySerializedFrame> end_stream( | 419 std::unique_ptr<SpdySerializedFrame> end_stream( |
400 spdy_util_.ConstructSpdyBodyFrame(1, nullptr, 0, true)); | 420 spdy_util_.ConstructSpdyBodyFrame(1, nullptr, 0, true)); |
401 MockWrite writes[] = { | 421 MockWrite writes[] = { |
402 CreateMockWrite(*req.get(), 0), | 422 CreateMockWrite(*req.get(), 0), |
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1507 AlternativeServiceVector alternative_service_vector = | 1527 AlternativeServiceVector alternative_service_vector = |
1508 http_session_->http_server_properties()->GetAlternativeServices(server); | 1528 http_session_->http_server_properties()->GetAlternativeServices(server); |
1509 ASSERT_EQ(1u, alternative_service_vector.size()); | 1529 ASSERT_EQ(1u, alternative_service_vector.size()); |
1510 EXPECT_EQ(AlternateProtocolFromNextProto(kProtoQUIC1SPDY3), | 1530 EXPECT_EQ(AlternateProtocolFromNextProto(kProtoQUIC1SPDY3), |
1511 alternative_service_vector[0].protocol); | 1531 alternative_service_vector[0].protocol); |
1512 EXPECT_EQ("www.example.org", alternative_service_vector[0].host); | 1532 EXPECT_EQ("www.example.org", alternative_service_vector[0].host); |
1513 EXPECT_EQ(443, alternative_service_vector[0].port); | 1533 EXPECT_EQ(443, alternative_service_vector[0].port); |
1514 } | 1534 } |
1515 | 1535 |
1516 } // namespace net | 1536 } // namespace net |
OLD | NEW |