1 // Copyright 2016 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef NET_TEST_QUIC_SIMPLE_TEST_SERVER_H_
6 #define NET_TEST_QUIC_SIMPLE_TEST_SERVER_H_
11 #include "base/time/time.h"
12 #include "net/base/host_port_pair.h"
13 #include "net/third_party/quiche/src/quiche/spdy/core/http2_header_block.h"
18 class QuicSimpleTestServer {
21 static void Shutdown();
23 // Shuts down the server dispatcher, which results in sending ConnectionClose
24 // frames to all connected clients.
25 static void ShutdownDispatcherForTesting();
27 // Add a response to `path`.
28 static void AddResponse(const std::string& path,
29 spdy::Http2HeaderBlock response_headers,
30 const std::string& response_body);
32 // Add a response to `path` with Early Hints.
33 static void AddResponseWithEarlyHints(
34 const std::string& path,
35 const spdy::Http2HeaderBlock& response_headers,
36 const std::string& response_body,
37 const std::vector<spdy::Http2HeaderBlock>& early_hints);
39 // Set a delay to `path`.
40 static void SetResponseDelay(const std::string& path, base::TimeDelta delay);
42 // Returns example.com
43 static std::string const GetDomain();
44 // Returns test.example.com
45 static std::string const GetHost();
46 // Returns port number of the server.
48 // Returns test.example.com:port
49 static HostPortPair const GetHostPort();
51 // Returns URL with host, port and file path, for example
52 // https://test.example.com:12345/{file_path}
53 static GURL GetFileURL(const std::string& file_path);
55 static std::string const GetStatusHeaderName();
57 // Server returns response with HTTP/2 headers and trailers. Does not include
58 // |port| as it is resolved differently: https://test.example.com/hello.txt
59 static GURL GetHelloURL();
60 static std::string const GetHelloPath();
61 static std::string const GetHelloBodyValue();
62 static std::string const GetHelloStatus();
63 static std::string const GetHelloHeaderName();
64 static std::string const GetHelloHeaderValue();
65 static std::string const GetCombinedHeaderName();
66 static std::string const GetHelloTrailerName();
67 static std::string const GetHelloTrailerValue();
69 // Server returns response without HTTP/2 trailers.
70 // https://test.example.com/simple.txt
71 static GURL GetSimpleURL();
72 static std::string const GetSimpleBodyValue();
73 static std::string const GetSimpleStatus();
74 static std::string const GetSimpleHeaderName();
75 static std::string const GetSimpleHeaderValue();
80 #endif // NET_TEST_QUIC_SIMPLE_TEST_SERVER_H_