#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "net/test/url_request/url_request_mock_data_job.h"
#include <memory>
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_runner.h"
#include "net/base/io_buffer.h"
#include "net/base/url_util.h"
#include "net/cert/x509_certificate.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_util.h"
#include "net/ssl/ssl_cert_request_info.h"
#include "net/ssl/ssl_private_key.h"
#include "net/url_request/url_request_filter.h"
namespace net {
namespace {
const char kMockHostname[] = …;
std::string GetDataFromRequest(const URLRequest& request) { … }
int GetRepeatCountFromRequest(const URLRequest& request) { … }
bool GetRequestClientCertificate(const URLRequest& request) { … }
GURL GetMockUrl(const std::string& scheme,
const std::string& hostname,
const std::string& data,
int data_repeat_count,
bool request_client_certificate) { … }
class MockJobInterceptor : public URLRequestInterceptor { … };
}
URLRequestMockDataJob::URLRequestMockDataJob(URLRequest* request,
const std::string& data,
int data_repeat_count,
bool request_client_certificate)
: … { … }
URLRequestMockDataJob::~URLRequestMockDataJob() = default;
void URLRequestMockDataJob::OverrideResponseHeaders(
const std::string& headers) { … }
void URLRequestMockDataJob::Start() { … }
int URLRequestMockDataJob::ReadRawData(IOBuffer* buf, int buf_size) { … }
void URLRequestMockDataJob::ContinueWithCertificate(
scoped_refptr<X509Certificate> client_cert,
scoped_refptr<SSLPrivateKey> client_private_key) { … }
void URLRequestMockDataJob::GetResponseInfo(HttpResponseInfo* info) { … }
void URLRequestMockDataJob::GetResponseInfoConst(HttpResponseInfo* info) const { … }
void URLRequestMockDataJob::StartAsync() { … }
void URLRequestMockDataJob::AddUrlHandler() { … }
void URLRequestMockDataJob::AddUrlHandlerForHostname(
const std::string& hostname) { … }
GURL URLRequestMockDataJob::GetMockHttpUrl(const std::string& data,
int repeat_count) { … }
GURL URLRequestMockDataJob::GetMockHttpsUrl(const std::string& data,
int repeat_count) { … }
GURL URLRequestMockDataJob::GetMockUrlForClientCertificateRequest() { … }
GURL URLRequestMockDataJob::GetMockHttpUrlForHostname(
const std::string& hostname,
const std::string& data,
int repeat_count) { … }
GURL URLRequestMockDataJob::GetMockHttpsUrlForHostname(
const std::string& hostname,
const std::string& data,
int repeat_count) { … }
}