chromium/net/proxy_resolution/pac_file_fetcher_impl.cc

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

#include "net/proxy_resolution/pac_file_fetcher_impl.h"

#include <string_view>

#include "base/compiler_specific.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_util.h"
#include "base/task/single_thread_task_runner.h"
#include "net/base/data_url.h"
#include "net/base/io_buffer.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
#include "net/base/net_string_util.h"
#include "net/base/request_priority.h"
#include "net/cert/cert_status_flags.h"
#include "net/http/http_response_headers.h"
#include "net/url_request/redirect_info.h"
#include "net/url_request/url_request_context.h"

// TODO(eroman):
//   - Support auth-prompts (http://crbug.com/77366)

namespace net {

namespace {

// The maximum size (in bytes) allowed for a PAC script. Responses exceeding
// this will fail with ERR_FILE_TOO_BIG.
const int kDefaultMaxResponseBytes =;  // 1 megabyte

// The maximum duration (in milliseconds) allowed for fetching the PAC script.
// Responses exceeding this will fail with ERR_TIMED_OUT.
//
// This timeout applies to both scripts fetched in the course of WPAD, as well
// as explicitly configured ones.
//
// If the default timeout is too high, auto-detect can stall for a long time,
// and if it is too low then slow loading scripts may be skipped.
//
// 30 seconds is a compromise between those competing goals. This value also
// appears to match Microsoft Edge (based on testing).
constexpr base::TimeDelta kDefaultMaxDuration =;

// Returns true if |mime_type| is one of the known PAC mime type.
constexpr bool IsPacMimeType(std::string_view mime_type) {}

struct BomMapping {};

const BomMapping kBomMappings[] =;

// Converts |bytes| (which is encoded by |charset|) to UTF16, saving the resul
// to |*utf16|.
// If |charset| is empty, then we don't know what it was and guess.
void ConvertResponseToUTF16(const std::string& charset,
                            const std::string& bytes,
                            std::u16string* utf16) {}

}  // namespace

std::unique_ptr<PacFileFetcherImpl> PacFileFetcherImpl::Create(
    URLRequestContext* url_request_context) {}

PacFileFetcherImpl::~PacFileFetcherImpl() {}

base::TimeDelta PacFileFetcherImpl::SetTimeoutConstraint(
    base::TimeDelta timeout) {}

size_t PacFileFetcherImpl::SetSizeConstraint(size_t size_bytes) {}

void PacFileFetcherImpl::OnResponseCompleted(URLRequest* request,
                                             int net_error) {}

int PacFileFetcherImpl::Fetch(
    const GURL& url,
    std::u16string* text,
    CompletionOnceCallback callback,
    const NetworkTrafficAnnotationTag traffic_annotation) {}

void PacFileFetcherImpl::Cancel() {}

URLRequestContext* PacFileFetcherImpl::GetRequestContext() const {}

void PacFileFetcherImpl::OnShutdown() {}

void PacFileFetcherImpl::OnReceivedRedirect(URLRequest* request,
                                            const RedirectInfo& redirect_info,
                                            bool* defer_redirect) {}

void PacFileFetcherImpl::OnAuthRequired(URLRequest* request,
                                        const AuthChallengeInfo& auth_info) {}

void PacFileFetcherImpl::OnSSLCertificateError(URLRequest* request,
                                               int net_error,
                                               const SSLInfo& ssl_info,
                                               bool fatal) {}

void PacFileFetcherImpl::OnResponseStarted(URLRequest* request, int net_error) {}

void PacFileFetcherImpl::OnReadCompleted(URLRequest* request, int num_bytes) {}

PacFileFetcherImpl::PacFileFetcherImpl(URLRequestContext* url_request_context)
    :{}

bool PacFileFetcherImpl::IsUrlSchemeAllowed(const GURL& url) const {}

void PacFileFetcherImpl::ReadBody(URLRequest* request) {}

bool PacFileFetcherImpl::ConsumeBytesRead(URLRequest* request, int num_bytes) {}

void PacFileFetcherImpl::FetchCompleted() {}

void PacFileFetcherImpl::ResetCurRequestState() {}

void PacFileFetcherImpl::OnTimeout(int id) {}

}  // namespace net