Files
EVEngine/src/modules/network/HttpRequest.h
T
西风逍遥游 4377e062dd feat: zeroerr parameter validation + Doxygen API documentation
Squashed onto current main. Adds src/engine/common/Assert.h (EV_PARAM_CHECK / EV_ASSERT backed by zeroerr), an EVENGINE_ENABLE_ASSERTS option (non-Debug builds strip ZEROERR_NO_ASSERT unless enabled), parameter checks at key entry points, Doxygen comments across headers, Doxyfile + make docs / CMake docs targets, and Windows setup + code conventions in AGENTS.md.
2026-08-19 09:01:12 +08:00

57 lines
1.5 KiB
C++

#pragma once
#include "NetTypes.h"
#include <cstdint>
#include <map>
#include <memory>
#include <string>
#include <vector>
namespace eve::data {
class ByteData;
}
namespace eve::network {
class Network;
/**
* @brief Asynchronous HTTP request (Poco-based). Configure headers/body, call
* submit(), then receive the response through Network::pump as a
* NetEvType::HttpResp completion.
*/
class HttpRequest {
public:
/** @brief Creates a request; method is e.g. "GET"/"POST", url is absolute. */
HttpRequest(Network* net, std::string method, std::string url);
~HttpRequest() = default;
/** @brief Sets one request header. */
void setHeader(std::string k, std::string v);
/** @brief Sets the request body bytes. */
void setBody(eve::data::ByteData* data);
/** @brief Sets the request body as a string. */
void setBodyString(std::string s);
/** @brief Overrides the module default timeout for this request (ms). */
void setTimeout(int ms);
/** @brief Overrides TLS verification for this request. */
void setVerifySsl(bool verify);
/** @brief Queues the request on the worker; true when accepted. */
bool submit();
/** @brief Owning module. */
Network* network() const { return net_; }
private:
Network* net_ = nullptr;
std::string method_;
std::string url_;
std::map<std::string, std::string> headers_;
std::shared_ptr<std::vector<char>> body_;
int timeoutMs_ = -1;
int verifySsl_ = -1; // -1 = use module default
};
} // namespace eve::network