#include "chrome/test/chromedriver/server/http_server.h"
#include "base/task/single_thread_task_runner.h"
#include "net/base/ip_endpoint.h"
#include "net/base/net_errors.h"
#include "net/base/network_interfaces.h"
#include "net/base/sys_addrinfo.h"
#include "url/gurl.h"
namespace {
const int kBufferSize = …;
const char kAnyHostPattern[] = …;
int ListenOnIPv4(net::ServerSocket* socket, uint16_t port, bool allow_remote) { … }
int ListenOnIPv6(net::ServerSocket* socket, uint16_t port, bool allow_remote) { … }
bool IsSimple(const std::string& hostname) { … }
bool IsMatch(const std::string& system_host, const std::string& hostname) { … }
void GetCanonicalHostName(std::vector<std::string>* canonical_host_names) { … }
bool HostIsSafeToServe(GURL host_url,
std::string host_header_value,
const std::vector<net::IPAddress>& whitelisted_ips,
const std::vector<std::string>& allowed_origins) { … }
bool RequestIsSafeToServe(const net::HttpServerRequestInfo& info,
bool allow_remote,
const std::vector<net::IPAddress>& whitelisted_ips,
const std::vector<std::string>& allowed_origins) { … }
}
HttpServer::HttpServer(const std::string& url_base,
const std::vector<net::IPAddress>& whitelisted_ips,
const std::vector<std::string>& allowed_origins,
const HttpRequestHandlerFunc& handle_request_func,
base::WeakPtr<HttpHandler> handler,
scoped_refptr<base::SingleThreadTaskRunner> cmd_runner)
: … { … }
int HttpServer::Start(uint16_t port, bool allow_remote, bool use_ipv4) { … }
const net::IPEndPoint& HttpServer::LocalAddress() const { … }
void HttpServer::OnConnect(int connection_id) { … }
void HttpServer::OnHttpRequest(int connection_id,
const net::HttpServerRequestInfo& info) { … }
HttpServer::~HttpServer() = default;
void HttpServer::OnWebSocketRequest(int connection_id,
const net::HttpServerRequestInfo& info) { … }
void HttpServer::OnWebSocketMessage(int connection_id, std::string data) { … }
void HttpServer::OnClose(int connection_id) { … }
void HttpServer::Close(int connection_id) { … }
void HttpServer::SendOverWebSocket(int connection_id, const std::string& data) { … }
void HttpServer::AcceptWebSocket(int connection_id,
const net::HttpServerRequestInfo& request) { … }
void HttpServer::SendResponse(
int connection_id,
const net::HttpServerResponseInfo& response,
const net::NetworkTrafficAnnotationTag& traffic_annotation) { … }
void HttpServer::OnResponse(
int connection_id,
bool keep_alive,
std::unique_ptr<net::HttpServerResponseInfo> response) { … }