chromium/third_party/perfetto/src/base/http/http_server.cc

/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#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 {};

// From https://datatracker.ietf.org/doc/html/rfc6455#section-1.3.
constexpr char kWebsocketGuid[] =;

}  // namespace

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*,  // The listening socket, irrelevant here.
    std::unique_ptr<UnixSocket> sock) {}

void HttpServer::OnConnect(UnixSocket*, bool) {}

void HttpServer::OnDisconnect(UnixSocket* sock) {}

void HttpServer::OnDataAvailable(UnixSocket* sock) {}

// Parses the HTTP request and invokes HandleRequest(). It returns the size of
// the HTTP header + body that has been processed or 0 if there isn't enough
// data for a full HTTP request in the buffer.
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*) {}

}  // namespace base
}  // namespace perfetto