chromium/services/network/oblivious_http_request_handler.cc

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "services/network/oblivious_http_request_handler.h"

#include <algorithm>
#include <array>

#include "base/i18n/time_formatting.h"
#include "base/not_fatal_until.h"
#include "base/rand_util.h"
#include "base/ranges/algorithm.h"
#include "mojo/public/cpp/bindings/remote_set.h"
#include "net/base/load_flags.h"
#include "net/http/http_log_util.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_status_code.h"
#include "net/http/http_util.h"
#include "net/log/net_log_capture_mode.h"
#include "net/log/net_log_values.h"
#include "net/log/net_log_with_source.h"
#include "net/third_party/quiche/src/quiche/binary_http/binary_http_message.h"
#include "net/third_party/quiche/src/quiche/oblivious_http/buffers/oblivious_http_request.h"
#include "net/third_party/quiche/src/quiche/oblivious_http/common/oblivious_http_header_key_config.h"
#include "net/third_party/quiche/src/quiche/oblivious_http/oblivious_http_client.h"
#include "services/network/cookie_manager.h"
#include "services/network/network_context.h"
#include "services/network/network_service.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/mojom/clear_data_filter.mojom.h"
#include "services/network/public/mojom/oblivious_http_request.mojom.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "services/network/trust_tokens/trust_token_request_helper_factory.h"

namespace network {

namespace {

constexpr size_t kMaxResponseSize =;  // Response size limit is 5MB
constexpr base::TimeDelta kDefaultRequestTimeout =;
constexpr char kObliviousHttpRequestMimeType[] =;

constexpr size_t kMaxMethodSize =;
constexpr size_t kMaxRequestBodySize =;                               // Request size limit is 5MB
constexpr size_t kMaxContentTypeSize =;        // Per RFC6838

// Class wrapping quiche::ObliviousHttpClient. Should be created once for each
// request/response pair.
class StatefulObliviousHttpClient {};

std::string CreateAndSerializeBhttpMessage(
    const GURL& request_url,
    const std::string& method,
    mojom::ObliviousHttpRequestBodyPtr request_body,
    net::HttpRequestHeaders::HeaderVector headers) {}

scoped_refptr<net::HttpResponseHeaders> GetSyntheticBhttpResponseHeader(
    const std::vector<quiche::BinaryHttpRequest::Field>& bhttp_headers) {}

}  // namespace

class ObliviousHttpRequestHandler::RequestState {};

ObliviousHttpRequestHandler::ObliviousHttpRequestHandler(
    NetworkContext* context)
    :{}

ObliviousHttpRequestHandler::~ObliviousHttpRequestHandler() = default;

void ObliviousHttpRequestHandler::StartRequest(
    mojom::ObliviousHttpRequestPtr ohttp_request,
    mojo::PendingRemote<mojom::ObliviousHttpClient> client) {}

void ObliviousHttpRequestHandler::OnDoneConstructingTrustTokenHelper(
    mojo::RemoteSetElementId id,
    TrustTokenStatusOrRequestHelper status_or_helper) {}

void ObliviousHttpRequestHandler::OnDoneBeginningTrustTokenOperation(
    mojo::RemoteSetElementId id,
    std::optional<net::HttpRequestHeaders> headers,
    mojom::TrustTokenOperationStatus status) {}

void ObliviousHttpRequestHandler::ContinueHandlingRequest(
    std::optional<net::HttpRequestHeaders> headers,
    mojo::RemoteSetElementId id) {}

void ObliviousHttpRequestHandler::RespondWithError(
    mojo::RemoteSetElementId id,
    int error_code,
    std::optional<int> outer_response_error_code) {}

void ObliviousHttpRequestHandler::OnRequestComplete(
    mojo::RemoteSetElementId id,
    std::unique_ptr<std::string> response) {}

void ObliviousHttpRequestHandler::OnDoneFinalizingTrustTokenOperation(
    mojo::RemoteSetElementId id,
    int inner_response_code,
    scoped_refptr<net::HttpResponseHeaders> headers,
    std::string body,
    mojom::TrustTokenOperationStatus status) {}

void ObliviousHttpRequestHandler::NotifyComplete(
    mojo::RemoteSetElementId id,
    int inner_response_code,
    scoped_refptr<net::HttpResponseHeaders> headers,
    std::string body) {}

void ObliviousHttpRequestHandler::OnClientDisconnect(
    mojo::RemoteSetElementId id) {}

network::mojom::URLLoaderFactory*
ObliviousHttpRequestHandler::GetURLLoaderFactory() {}

}  // namespace network