#include "perfetto/ext/base/http/http_server.h"
#include <cinttypes>
#include <vector>
#include "perfetto/ext/base/base64.h"
#include "perfetto/ext/base/endian.h"
#include "perfetto/ext/base/http/sha1.h"
#include "perfetto/ext/base/string_utils.h"
#include "perfetto/ext/base/string_view.h"
namespace perfetto {
namespace base {
namespace {
constexpr size_t kMaxPayloadSize = …;
constexpr size_t kMaxRequestSize = …;
enum WebsocketOpcode : uint8_t { … };
constexpr char kWebsocketGuid[] = …;
}
HttpServer::HttpServer(TaskRunner* task_runner, HttpRequestHandler* req_handler)
: … { … }
HttpServer::~HttpServer() = default;
void HttpServer::Start(int port) { … }
void HttpServer::AddAllowedOrigin(const std::string& origin) { … }
void HttpServer::OnNewIncomingConnection(
UnixSocket*,
std::unique_ptr<UnixSocket> sock) { … }
void HttpServer::OnConnect(UnixSocket*, bool) { … }
void HttpServer::OnDisconnect(UnixSocket* sock) { … }
void HttpServer::OnDataAvailable(UnixSocket* sock) { … }
size_t HttpServer::ParseOneHttpRequest(HttpServerConnection* conn) { … }
void HttpServer::HandleCorsPreflightRequest(const HttpRequest& req) { … }
bool HttpServer::IsOriginAllowed(StringView origin) { … }
void HttpServerConnection::UpgradeToWebsocket(const HttpRequest& req) { … }
size_t HttpServer::ParseOneWebsocketFrame(HttpServerConnection* conn) { … }
void HttpServerConnection::SendResponseHeaders(
const char* http_code,
std::initializer_list<const char*> headers,
size_t content_length) { … }
void HttpServerConnection::SendResponseBody(const void* data, size_t len) { … }
void HttpServerConnection::Close() { … }
void HttpServerConnection::SendResponse(
const char* http_code,
std::initializer_list<const char*> headers,
StringView content,
bool force_close) { … }
void HttpServerConnection::SendWebsocketMessage(const void* data, size_t len) { … }
void HttpServerConnection::SendWebsocketFrame(uint8_t opcode,
const void* payload,
size_t payload_len) { … }
HttpServerConnection::HttpServerConnection(std::unique_ptr<UnixSocket> s)
: … { … }
HttpServerConnection::~HttpServerConnection() = default;
std::optional<StringView> HttpRequest::GetHeader(StringView name) const { … }
HttpRequestHandler::~HttpRequestHandler() = default;
void HttpRequestHandler::OnWebsocketMessage(const WebsocketMessage&) { … }
void HttpRequestHandler::OnHttpConnectionClosed(HttpServerConnection*) { … }
}
}