#include "net/test/embedded_test_server/default_handlers.h"
#include <ctime>
#include <map>
#include <memory>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include "base/base64.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/functional/callback_helpers.h"
#include "base/hash/md5.h"
#include "base/logging.h"
#include "base/memory/weak_ptr.h"
#include "base/path_service.h"
#include "base/strings/escape.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "base/unguessable_token.h"
#include "net/base/host_port_pair.h"
#include "net/base/url_util.h"
#include "net/filter/filter_source_stream_test_util.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
#include "net/test/embedded_test_server/request_handler_util.h"
namespace net::test_server {
namespace {
const char kDefaultRealm[] = …;
const char kDefaultPassword[] = …;
const char kEtag[] = …;
const char kLogoPath[] = …;
std::unique_ptr<HttpResponse> HandleDefaultConnect(const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleCacheTime(const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleEchoHeader(const std::string& url,
const std::string& cache_control,
const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleEchoCookieWithStatus(
const std::string& url,
const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleEchoCriticalHeader(
const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleEcho(const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleEchoTitle(const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleEchoAll(const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleEchoRaw(const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleSetCookie(const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleSetInvalidCookie(
const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleExpectAndSetCookie(
const HttpRequest& request) { … }
std::map<std::string, std::string> ExtractHeadersFromQuery(const GURL& url) { … }
std::unique_ptr<HttpResponse> HandleSetHeader(const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleSetHeaderWithFile(
const std::string& prefix,
const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleIframe(const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleNoContent(const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleCloseSocket(const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleAuthBasic(const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleAuthDigest(const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleServerRedirect(HttpStatusCode redirect_code,
bool allow_cors,
const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleServerRedirectWithCookie(
HttpStatusCode redirect_code,
const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleServerRedirectWithSecureCookie(
HttpStatusCode redirect_code,
const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleCrossSiteRedirect(
EmbeddedTestServer* server,
const std::string& prefix,
bool set_cookie,
const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleClientRedirect(const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleDefaultResponse(
const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleSlowServer(const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleHungResponse(const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleHungAfterHeadersResponse(
const HttpRequest& request) { … }
class ExabyteResponse : public BasicHttpResponse { … };
std::unique_ptr<HttpResponse> HandleExabyteResponse(
const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleGzipBody(const HttpRequest& request) { … }
std::unique_ptr<HttpResponse> HandleSelfPac(const HttpRequest& request) { … }
class DelayedChunkedHttpResponse : public HttpResponse { … };
std::unique_ptr<HttpResponse> HandleChunked(const HttpRequest& request) { … }
EmbeddedTestServer::HandleRequestCallback PrefixHandler(
const std::string& prefix,
std::unique_ptr<HttpResponse> (*handler)(const HttpRequest& request)) { … }
EmbeddedTestServer::HandleRequestCallback ServerRedirectHandler(
const std::string& prefix,
std::unique_ptr<HttpResponse> (*handler)(HttpStatusCode redirect_code,
bool allow_cors,
const HttpRequest& request),
HttpStatusCode redirect_code) { … }
EmbeddedTestServer::HandleRequestCallback NoCorsServerRedirectHandler(
const std::string& prefix,
std::unique_ptr<HttpResponse> (*handler)(HttpStatusCode redirect_code,
bool allow_cors,
const HttpRequest& request),
HttpStatusCode redirect_code) { … }
EmbeddedTestServer::HandleRequestCallback ServerRedirectWithCookieHandler(
const std::string& prefix,
std::unique_ptr<HttpResponse> (*handler)(HttpStatusCode redirect_code,
const HttpRequest& request),
HttpStatusCode redirect_code) { … }
}
void RegisterDefaultHandlers(EmbeddedTestServer* server) { … }
}