| 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 "net/tools/quic/test_tools/quic_test_client.h" | 5 #include "net/tools/quic/test_tools/quic_test_client.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 } | 431 } |
| 432 | 432 |
| 433 bool QuicTestClient::buffer_body() const { | 433 bool QuicTestClient::buffer_body() const { |
| 434 return buffer_body_; | 434 return buffer_body_; |
| 435 } | 435 } |
| 436 | 436 |
| 437 void QuicTestClient::set_buffer_body(bool buffer_body) { | 437 void QuicTestClient::set_buffer_body(bool buffer_body) { |
| 438 buffer_body_ = buffer_body; | 438 buffer_body_ = buffer_body; |
| 439 } | 439 } |
| 440 | 440 |
| 441 bool QuicTestClient::ServerInLameDuckMode() const { | |
| 442 return false; | |
| 443 } | |
| 444 | |
| 445 const string& QuicTestClient::response_body() { | 441 const string& QuicTestClient::response_body() { |
| 446 return response_; | 442 return response_; |
| 447 } | 443 } |
| 448 | 444 |
| 449 string QuicTestClient::SendCustomSynchronousRequest( | 445 string QuicTestClient::SendCustomSynchronousRequest( |
| 450 const HTTPMessage& message) { | 446 const HTTPMessage& message) { |
| 451 if (SendMessage(message) == 0) { | 447 if (SendMessage(message) == 0) { |
| 452 DLOG(ERROR) << "Failed the request for uri:" | 448 DLOG(ERROR) << "Failed the request for uri:" |
| 453 << message.headers()->request_uri(); | 449 << message.headers()->request_uri(); |
| 454 // Set the response_ explicitly. Otherwise response_ will contain the | 450 // Set the response_ explicitly. Otherwise response_ will contain the |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 | 687 |
| 692 void QuicTestClient::UseWriter(QuicPacketWriterWrapper* writer) { | 688 void QuicTestClient::UseWriter(QuicPacketWriterWrapper* writer) { |
| 693 client_->UseWriter(writer); | 689 client_->UseWriter(writer); |
| 694 } | 690 } |
| 695 | 691 |
| 696 void QuicTestClient::UseConnectionId(QuicConnectionId connection_id) { | 692 void QuicTestClient::UseConnectionId(QuicConnectionId connection_id) { |
| 697 DCHECK(!connected()); | 693 DCHECK(!connected()); |
| 698 client_->UseConnectionId(connection_id); | 694 client_->UseConnectionId(connection_id); |
| 699 } | 695 } |
| 700 | 696 |
| 701 ssize_t QuicTestClient::SendAndWaitForResponse(const void* buffer, | |
| 702 size_t size) { | |
| 703 LOG(DFATAL) << "Not implemented"; | |
| 704 return 0; | |
| 705 } | |
| 706 | |
| 707 void QuicTestClient::Bind(IPEndPoint* local_address) { | |
| 708 DLOG(WARNING) << "Bind will be done during connect"; | |
| 709 } | |
| 710 | |
| 711 void QuicTestClient::MigrateSocket(const IPAddress& new_host) { | 697 void QuicTestClient::MigrateSocket(const IPAddress& new_host) { |
| 712 client_->MigrateSocket(new_host); | 698 client_->MigrateSocket(new_host); |
| 713 } | 699 } |
| 714 | 700 |
| 715 string QuicTestClient::SerializeMessage(const HTTPMessage& message) { | |
| 716 LOG(DFATAL) << "Not implemented"; | |
| 717 return ""; | |
| 718 } | |
| 719 | |
| 720 IPAddress QuicTestClient::bind_to_address() const { | 701 IPAddress QuicTestClient::bind_to_address() const { |
| 721 return client_->bind_to_address(); | 702 return client_->bind_to_address(); |
| 722 } | 703 } |
| 723 | 704 |
| 724 void QuicTestClient::set_bind_to_address(const IPAddress& address) { | 705 void QuicTestClient::set_bind_to_address(IPAddress address) { |
| 725 client_->set_bind_to_address(address); | 706 client_->set_bind_to_address(address); |
| 726 } | 707 } |
| 727 | 708 |
| 728 const IPEndPoint& QuicTestClient::address() const { | 709 const IPEndPoint& QuicTestClient::address() const { |
| 729 return client_->server_address(); | 710 return client_->server_address(); |
| 730 } | 711 } |
| 731 | 712 |
| 732 size_t QuicTestClient::requests_sent() const { | |
| 733 LOG(DFATAL) << "Not implemented"; | |
| 734 return 0; | |
| 735 } | |
| 736 | |
| 737 void QuicTestClient::WaitForWriteToFlush() { | 713 void QuicTestClient::WaitForWriteToFlush() { |
| 738 while (connected() && client()->session()->HasDataToWrite()) { | 714 while (connected() && client()->session()->HasDataToWrite()) { |
| 739 client_->WaitForEvents(); | 715 client_->WaitForEvents(); |
| 740 } | 716 } |
| 741 } | 717 } |
| 742 | 718 |
| 743 void QuicTestClient::TestClientDataToResend::Resend() { | 719 void QuicTestClient::TestClientDataToResend::Resend() { |
| 744 BalsaHeaders balsa_headers; | 720 BalsaHeaders balsa_headers; |
| 745 SpdyBalsaUtils::SpdyHeadersToRequestHeaders(*headers_, &balsa_headers); | 721 SpdyBalsaUtils::SpdyHeadersToRequestHeaders(*headers_, &balsa_headers); |
| 746 test_client_->GetOrCreateStreamAndSendRequest(&balsa_headers, body_, fin_, | 722 test_client_->GetOrCreateStreamAndSendRequest(&balsa_headers, body_, fin_, |
| 747 delegate_); | 723 delegate_); |
| 748 headers_.reset(); | 724 headers_.reset(); |
| 749 } | 725 } |
| 750 | 726 |
| 751 // static | 727 // static |
| 752 void QuicTestClient::FillInRequest(const string& uri, HTTPMessage* message) { | 728 void QuicTestClient::FillInRequest(const string& uri, HTTPMessage* message) { |
| 753 CHECK(message); | 729 CHECK(message); |
| 754 message->headers()->SetRequestVersion( | 730 message->headers()->SetRequestVersion( |
| 755 HTTPMessage::VersionToString(HttpConstants::HTTP_1_1)); | 731 HTTPMessage::VersionToString(HttpConstants::HTTP_1_1)); |
| 756 message->headers()->SetRequestMethod( | 732 message->headers()->SetRequestMethod( |
| 757 HTTPMessage::MethodToString(HttpConstants::GET)); | 733 HTTPMessage::MethodToString(HttpConstants::GET)); |
| 758 message->headers()->SetRequestUri(uri); | 734 message->headers()->SetRequestUri(uri); |
| 759 } | 735 } |
| 760 | 736 |
| 761 } // namespace test | 737 } // namespace test |
| 762 } // namespace net | 738 } // namespace net |
| OLD | NEW |