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 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 bool last_data, | 414 bool last_data, |
415 QuicAckListenerInterface* delegate) { | 415 QuicAckListenerInterface* delegate) { |
416 return GetOrCreateStreamAndSendRequest(nullptr, StringPiece(data), last_data, | 416 return GetOrCreateStreamAndSendRequest(nullptr, StringPiece(data), last_data, |
417 delegate); | 417 delegate); |
418 } | 418 } |
419 | 419 |
420 bool QuicTestClient::response_complete() const { | 420 bool QuicTestClient::response_complete() const { |
421 return response_complete_; | 421 return response_complete_; |
422 } | 422 } |
423 | 423 |
424 int QuicTestClient::response_header_size() const { | |
425 return response_header_size_; | |
426 } | |
427 | |
428 int64_t QuicTestClient::response_body_size() const { | 424 int64_t QuicTestClient::response_body_size() const { |
429 return response_body_size_; | 425 return response_body_size_; |
430 } | 426 } |
431 | 427 |
432 bool QuicTestClient::buffer_body() const { | 428 bool QuicTestClient::buffer_body() const { |
433 return buffer_body_; | 429 return buffer_body_; |
434 } | 430 } |
435 | 431 |
436 void QuicTestClient::set_buffer_body(bool buffer_body) { | 432 void QuicTestClient::set_buffer_body(bool buffer_body) { |
437 buffer_body_ = buffer_body; | 433 buffer_body_ = buffer_body; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 IPEndPoint QuicTestClient::local_address() const { | 541 IPEndPoint QuicTestClient::local_address() const { |
546 return client_->GetLatestClientAddress(); | 542 return client_->GetLatestClientAddress(); |
547 } | 543 } |
548 | 544 |
549 void QuicTestClient::ClearPerRequestState() { | 545 void QuicTestClient::ClearPerRequestState() { |
550 stream_error_ = QUIC_STREAM_NO_ERROR; | 546 stream_error_ = QUIC_STREAM_NO_ERROR; |
551 stream_ = nullptr; | 547 stream_ = nullptr; |
552 response_ = ""; | 548 response_ = ""; |
553 response_complete_ = false; | 549 response_complete_ = false; |
554 response_headers_complete_ = false; | 550 response_headers_complete_ = false; |
555 response_headers_.Clear(); | 551 response_headers_.clear(); |
556 bytes_read_ = 0; | 552 bytes_read_ = 0; |
557 bytes_written_ = 0; | 553 bytes_written_ = 0; |
558 response_header_size_ = 0; | |
559 response_body_size_ = 0; | 554 response_body_size_ = 0; |
560 } | 555 } |
561 | 556 |
562 bool QuicTestClient::HaveActiveStream() { | 557 bool QuicTestClient::HaveActiveStream() { |
563 return push_promise_data_to_resend_.get() || | 558 return push_promise_data_to_resend_.get() || |
564 (stream_ != nullptr && | 559 (stream_ != nullptr && |
565 !client_->session()->IsClosedStream(stream_->id())); | 560 !client_->session()->IsClosedStream(stream_->id())); |
566 } | 561 } |
567 | 562 |
568 bool QuicTestClient::WaitUntil(int timeout_ms, std::function<bool()> trigger) { | 563 bool QuicTestClient::WaitUntil(int timeout_ms, std::function<bool()> trigger) { |
(...skipping 25 matching lines...) Expand all Loading... |
594 return SendData(string(static_cast<const char*>(buffer), size), false); | 589 return SendData(string(static_cast<const char*>(buffer), size), false); |
595 } | 590 } |
596 | 591 |
597 bool QuicTestClient::response_headers_complete() const { | 592 bool QuicTestClient::response_headers_complete() const { |
598 if (stream_ != nullptr) { | 593 if (stream_ != nullptr) { |
599 return stream_->headers_decompressed(); | 594 return stream_->headers_decompressed(); |
600 } | 595 } |
601 return response_headers_complete_; | 596 return response_headers_complete_; |
602 } | 597 } |
603 | 598 |
604 const BalsaHeaders* QuicTestClient::response_headers() const { | 599 const SpdyHeaderBlock* QuicTestClient::response_headers() const { |
605 if (stream_ != nullptr) { | 600 if (stream_ != nullptr) { |
606 SpdyBalsaUtils::SpdyHeadersToResponseHeaders(stream_->response_headers(), | 601 response_headers_ = stream_->response_headers().Clone(); |
607 &response_headers_); | |
608 return &response_headers_; | |
609 } else { | |
610 return &response_headers_; | |
611 } | 602 } |
| 603 return &response_headers_; |
612 } | 604 } |
613 | 605 |
614 const SpdyHeaderBlock& QuicTestClient::response_trailers() const { | 606 const SpdyHeaderBlock& QuicTestClient::response_trailers() const { |
615 return response_trailers_; | 607 return response_trailers_; |
616 } | 608 } |
617 | 609 |
618 int64_t QuicTestClient::response_size() const { | 610 int64_t QuicTestClient::response_size() const { |
619 return bytes_read(); | 611 return bytes_read(); |
620 } | 612 } |
621 | 613 |
(...skipping 26 matching lines...) Expand all Loading... |
648 } | 640 } |
649 if (stream_ != stream) { | 641 if (stream_ != stream) { |
650 return; | 642 return; |
651 } | 643 } |
652 if (buffer_body()) { | 644 if (buffer_body()) { |
653 // TODO(fnk): The stream still buffers the whole thing. Fix that. | 645 // TODO(fnk): The stream still buffers the whole thing. Fix that. |
654 response_ = stream_->data(); | 646 response_ = stream_->data(); |
655 } | 647 } |
656 response_complete_ = true; | 648 response_complete_ = true; |
657 response_headers_complete_ = stream_->headers_decompressed(); | 649 response_headers_complete_ = stream_->headers_decompressed(); |
658 SpdyBalsaUtils::SpdyHeadersToResponseHeaders(stream_->response_headers(), | 650 response_headers_ = stream_->response_headers().Clone(); |
659 &response_headers_); | |
660 response_trailers_ = stream_->received_trailers().Clone(); | 651 response_trailers_ = stream_->received_trailers().Clone(); |
661 stream_error_ = stream_->stream_error(); | 652 stream_error_ = stream_->stream_error(); |
662 bytes_read_ = stream_->stream_bytes_read() + stream_->header_bytes_read(); | 653 bytes_read_ = stream_->stream_bytes_read() + stream_->header_bytes_read(); |
663 bytes_written_ = | 654 bytes_written_ = |
664 stream_->stream_bytes_written() + stream_->header_bytes_written(); | 655 stream_->stream_bytes_written() + stream_->header_bytes_written(); |
665 response_header_size_ = response_headers_.GetSizeForWriteBuffer(); | |
666 response_body_size_ = stream_->data().size(); | 656 response_body_size_ = stream_->data().size(); |
667 stream_ = nullptr; | 657 stream_ = nullptr; |
668 } | 658 } |
669 | 659 |
670 bool QuicTestClient::CheckVary(const SpdyHeaderBlock& client_request, | 660 bool QuicTestClient::CheckVary(const SpdyHeaderBlock& client_request, |
671 const SpdyHeaderBlock& promise_request, | 661 const SpdyHeaderBlock& promise_request, |
672 const SpdyHeaderBlock& promise_response) { | 662 const SpdyHeaderBlock& promise_response) { |
673 return true; | 663 return true; |
674 } | 664 } |
675 | 665 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 CHECK(message); | 718 CHECK(message); |
729 message->headers()->SetRequestVersion( | 719 message->headers()->SetRequestVersion( |
730 HTTPMessage::VersionToString(HttpConstants::HTTP_1_1)); | 720 HTTPMessage::VersionToString(HttpConstants::HTTP_1_1)); |
731 message->headers()->SetRequestMethod( | 721 message->headers()->SetRequestMethod( |
732 HTTPMessage::MethodToString(HttpConstants::GET)); | 722 HTTPMessage::MethodToString(HttpConstants::GET)); |
733 message->headers()->SetRequestUri(uri); | 723 message->headers()->SetRequestUri(uri); |
734 } | 724 } |
735 | 725 |
736 } // namespace test | 726 } // namespace test |
737 } // namespace net | 727 } // namespace net |
OLD | NEW |