#include "util/net/http_transport.h"
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <memory>
#include <utility>
#include <vector>
#include "base/files/file_path.h"
#include "base/format_macros.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "gtest/gtest.h"
#include "test/multiprocess_exec.h"
#include "test/test_paths.h"
#include "util/file/file_io.h"
#include "util/misc/random_string.h"
#include "util/net/http_body.h"
#include "util/net/http_headers.h"
#include "util/net/http_multipart_builder.h"
namespace crashpad {
namespace test {
namespace {
#if BUILDFLAG(IS_WIN)
std::string ToUTF8IfWin(const std::wstring& x) {
return base::WideToUTF8(x);
}
#else
std::string ToUTF8IfWin(const std::string& x) { … }
#endif
class HTTPTransportTestFixture : public MultiprocessExec { … };
constexpr char kMultipartFormData[] = …;
void GetHeaderField(const std::string& request,
const std::string& header,
std::string* value) { … }
void GetMultipartBoundary(const std::string& request,
std::string* multipart_boundary) { … }
constexpr char kBoundaryEq[] = …;
void ValidFormData(HTTPTransportTestFixture* fixture,
const std::string& request) { … }
class HTTPTransport : public testing::TestWithParam<std::string> { … };
TEST_P(HTTPTransport, ValidFormData) { … }
TEST_P(HTTPTransport, ValidFormData_Gzip) { … }
constexpr char kTextPlain[] = …;
void ErrorResponse(HTTPTransportTestFixture* fixture,
const std::string& request) { … }
TEST_P(HTTPTransport, ErrorResponse) { … }
constexpr char kTextBody[] = …;
void UnchunkedPlainText(HTTPTransportTestFixture* fixture,
const std::string& request) { … }
TEST_P(HTTPTransport, UnchunkedPlainText) { … }
void RunUpload33k(const std::string& scheme, bool has_content_length) { … }
TEST_P(HTTPTransport, Upload33k) { … }
TEST_P(HTTPTransport, Upload33k_LengthUnknown) { … }
#if defined(CRASHPAD_USE_BORINGSSL) && !BUILDFLAG(IS_FUCHSIA)
INSTANTIATE_TEST_SUITE_P(…);
#else
INSTANTIATE_TEST_SUITE_P(HTTPTransport,
HTTPTransport,
testing::Values("http"),
[](const testing::TestParamInfo<std::string>& info) {
return info.param;
});
#endif
}
}
}