// 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. #ifndef NET_TEST_EMBEDDED_TEST_SERVER_HTTP_REQUEST_H_ #define NET_TEST_EMBEDDED_TEST_SERVER_HTTP_REQUEST_H_ #include <stddef.h> #include <map> #include <memory> #include <optional> #include <string> #include <string_view> #include "base/strings/string_util.h" #include "net/ssl/ssl_info.h" #include "url/gurl.h" namespace net { class HttpChunkedDecoder; namespace test_server { // Methods of HTTP requests supported by the test HTTP server. enum HttpMethod { … }; // Represents a HTTP request. Since it can be big, `use std::unique_ptr` to pass // it instead of copying. However, the struct is copyable so tests can save and // examine a HTTP request. struct HttpRequest { … }; // Parses the input data and produces a valid HttpRequest object. If there is // more than one request in one chunk, then only the first one will be parsed. // The common use is as below: // HttpRequestParser parser; // (...) // void OnDataChunkReceived(Socket* socket, const char* data, int size) { // parser.ProcessChunk(std::string(data, size)); // if (parser.ParseRequest() == HttpRequestParser::ACCEPTED) { // std::unique_ptr<HttpRequest> request = parser.GetRequest(); // (... process the request ...) // } class HttpRequestParser { … }; } // namespace test_server } // namespace net #endif // NET_TEST_EMBEDDED_TEST_SERVER_HTTP_REQUEST_H_