123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- /*
- * request.h
- *
- * Created on: 2021年8月16日
- * Author: pengzc
- */
- #ifndef JNI_HTTP_REQUEST_H_
- #define JNI_HTTP_REQUEST_H_
- #include <string>
- #include <map>
- namespace base {
- class HttpClient;
- class HttpRequest {
- public:
- /**
- * GET / POST
- */
- HttpRequest(const std::string& method, const std::string& url,
- const std::string& body);
- virtual ~HttpRequest();
- public:
- typedef struct {
- double totalTime;
- double nameLookupTime;
- double connectTime;
- double appConnectTime;
- double preTransferTime;
- double startTransferTime;
- double redirectTime;
- int redirectCount;
- } RequestInfo;
- typedef struct {
- std::string baseUrl;
- int timeout;
- bool followRedirects;
- int maxRedirects;
- bool noSignal;
- struct {
- std::string username;
- std::string password;
- } basicAuth;
- std::string certPath;
- std::string certType;
- std::string keyPath;
- std::string keyPassword;
- std::string customUserAgent;
- std::string uriProxy;
- RequestInfo lastRequest;
- } Info;
- typedef std::map<std::string, std::string> Multiparts;
- // Instance configuration methods
- // configure basic auth
- void SetBasicAuth(const std::string& username,
- const std::string& password);
- // append additional headers
- HttpRequest& AppendHeader(const std::string& key,
- const std::string& value);
- //Header Content-Type
- HttpRequest& ContentType(const std::string& content_type);
- //Multipart/form data
- HttpRequest& AppendPart(const std::string& name, const std::string& value);
- private:
- friend class HttpClient;
- std::string method_;
- std::string url_;
- std::string body_;
- typedef std::map<std::string, std::string> HeaderFields;
- HeaderFields header;
- bool followRedirects;
- int maxRedirects;
- struct {
- std::string username;
- std::string password;
- } basicAuth;
- Multiparts multiparts_;
- };
- } /* namespace base */
- #endif /* JNI_HTTP_REQUEST_H_ */
|