载入中...
搜索中...
未找到
HttpRequest.h
浏览该文件的文档.
1#pragma once
2
3#include "NetTypes.h"
4
5#include <cstdint>
6#include <map>
7#include <memory>
8#include <string>
9#include <vector>
10
11namespace eve::data {
12class ByteData;
13}
14
15namespace eve::network {
16
17class Network;
18
25public:
27 HttpRequest(Network* net, std::string method, std::string url);
28 ~HttpRequest() = default;
29
31 void setHeader(std::string k, std::string v);
33 void setBody(eve::data::ByteData* data);
35 void setBodyString(std::string s);
37 void setTimeout(int ms);
39 void setVerifySsl(bool verify);
41 bool submit();
42
44 Network* network() const { return net_; }
45
46private:
47 Network* net_ = nullptr;
48 std::string method_;
49 std::string url_;
50 std::map<std::string, std::string> headers_;
51 std::shared_ptr<std::vector<char>> body_;
52 int timeoutMs_ = -1;
53 int verifySsl_ = -1; // -1 = use module default
54};
55
56} // namespace eve::network
int v
uint32_t s
Definition Weather.cpp:28
In-memory byte buffer implementing eve::Data (ref-counted).
Definition ByteData.h:11
Asynchronous HTTP request (Poco-based). Configure headers/body, call submit(), then receive the respo...
Definition HttpRequest.h:24
void setBodyString(std::string s)
Sets the request body as a string.
void setTimeout(int ms)
Overrides the module default timeout for this request (ms).
Network * network() const
Owning module.
Definition HttpRequest.h:44
void setBody(eve::data::ByteData *data)
Sets the request body bytes.
void setHeader(std::string k, std::string v)
Sets one request header.
bool submit()
Queues the request on the worker; true when accepted.
void setVerifySsl(bool verify)
Overrides TLS verification for this request.
Network module: TCP/UDP/HTTP factories, background worker, and completion event plumbing....
Definition Network.h:30