rch | 86a4562 | 2019-05-15 19:19:04 -0700 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // A toy client, which connects to a specified port and sends QUIC |
| 6 | // requests to that endpoint. |
| 7 | |
| 8 | #ifndef QUICHE_QUIC_TOOLS_QUIC_TOY_CLIENT_H_ |
| 9 | #define QUICHE_QUIC_TOOLS_QUIC_TOY_CLIENT_H_ |
| 10 | |
rch | 8474fd7 | 2019-05-16 10:25:04 -0700 | [diff] [blame] | 11 | #include "net/third_party/quiche/src/quic/tools/quic_spdy_client_base.h" |
rch | 86a4562 | 2019-05-15 19:19:04 -0700 | [diff] [blame] | 12 | |
| 13 | namespace quic { |
| 14 | |
rch | d914250 | 2019-05-17 14:31:14 -0700 | [diff] [blame] | 15 | class QuicToyClient { |
rch | 86a4562 | 2019-05-15 19:19:04 -0700 | [diff] [blame] | 16 | public: |
| 17 | class ClientFactory { |
| 18 | public: |
| 19 | virtual ~ClientFactory() = default; |
| 20 | |
wub | 4ea2ddf | 2019-06-10 15:55:10 -0700 | [diff] [blame] | 21 | // Creates a new client configured to connect to |host_for_lookup:port| |
| 22 | // supporting |versions|, using |host_for_handshake| for handshake and |
| 23 | // |verifier| to verify proofs. |
rch | 86a4562 | 2019-05-15 19:19:04 -0700 | [diff] [blame] | 24 | virtual std::unique_ptr<QuicSpdyClientBase> CreateClient( |
wub | 4ea2ddf | 2019-06-10 15:55:10 -0700 | [diff] [blame] | 25 | std::string host_for_handshake, |
| 26 | std::string host_for_lookup, |
rch | 86a4562 | 2019-05-15 19:19:04 -0700 | [diff] [blame] | 27 | uint16_t port, |
| 28 | ParsedQuicVersionVector versions, |
| 29 | std::unique_ptr<ProofVerifier> verifier) = 0; |
| 30 | }; |
| 31 | |
| 32 | // Constructs a new toy client that will use |client_factory| to create the |
| 33 | // actual QuicSpdyClientBase instance. |
rch | d914250 | 2019-05-17 14:31:14 -0700 | [diff] [blame] | 34 | QuicToyClient(ClientFactory* client_factory); |
rch | 86a4562 | 2019-05-15 19:19:04 -0700 | [diff] [blame] | 35 | |
| 36 | // Connects to the QUIC server based on the various flags defined in the |
| 37 | // .cc file, sends requests and prints the responses. Returns 0 on success |
| 38 | // and non-zero otherwise. |
| 39 | int SendRequestsAndPrintResponses(std::vector<std::string> urls); |
| 40 | |
| 41 | private: |
| 42 | ClientFactory* client_factory_; // Unowned. |
| 43 | }; |
| 44 | |
| 45 | } // namespace quic |
| 46 | |
| 47 | #endif // QUICHE_QUIC_TOOLS_QUIC_TOY_CLIENT_H_ |