blob: 1a201225a58d5e64e2948412d951f2268fd1ec11 [file] [log] [blame]
rch86a45622019-05-15 19:19:04 -07001// 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
rch8474fd72019-05-16 10:25:04 -070011#include "net/third_party/quiche/src/quic/tools/quic_spdy_client_base.h"
rch86a45622019-05-15 19:19:04 -070012
13namespace quic {
14
rchd9142502019-05-17 14:31:14 -070015class QuicToyClient {
rch86a45622019-05-15 19:19:04 -070016 public:
17 class ClientFactory {
18 public:
19 virtual ~ClientFactory() = default;
20
wub4ea2ddf2019-06-10 15:55:10 -070021 // 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.
rch86a45622019-05-15 19:19:04 -070024 virtual std::unique_ptr<QuicSpdyClientBase> CreateClient(
wub4ea2ddf2019-06-10 15:55:10 -070025 std::string host_for_handshake,
26 std::string host_for_lookup,
rch86a45622019-05-15 19:19:04 -070027 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.
rchd9142502019-05-17 14:31:14 -070034 QuicToyClient(ClientFactory* client_factory);
rch86a45622019-05-15 19:19:04 -070035
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_