1#ifndef TENDUKE_HTTP_HTTPREQUEST_H
2#define TENDUKE_HTTP_HTTPREQUEST_H
4#include "./HTTPRequestAuthenticator.h"
42 const std::multimap<std::string, std::string> &headers = std::multimap<std::string, std::string>(),
43 std::shared_ptr<const tenduke::http::HTTPRequestAuthenticator> requestAuthenticator =
nullptr,
44 std::string messageBody =
"",
47 ) : method(std::move(method)), messageBody(std::move(messageBody)), url(std::move(url)),
48 headers(headers), requestAuthenticator(std::move(requestAuthenticator)),
49 connectionTimeoutMs(connectionTimeoutMs), timeoutMs(timeoutMs)
62 const std::string &
getMethod()
const {
return method;}
68 const ::tenduke::net::URL
getURL()
const {
return url;}
74 const std::multimap<std::string, std::string> &
getHeaders()
const {
return headers;}
80 const std::shared_ptr<const tenduke::http::HTTPRequestAuthenticator> &
getRequestAuthenticator()
const {
return requestAuthenticator;}
98 bool hasBody()
const {
return !messageBody.empty();}
101 const std::string method;
102 const std::string messageBody;
103 const ::tenduke::net::URL url;
104 const std::multimap<std::string, std::string> headers;
105 const std::shared_ptr<const tenduke::http::HTTPRequestAuthenticator> requestAuthenticator;
106 const long connectionTimeoutMs;
107 const long timeoutMs;
HTTPRequest(std::string method, ::tenduke::net::URL url, const std::multimap< std::string, std::string > &headers=std::multimap< std::string, std::string >(), std::shared_ptr< const tenduke::http::HTTPRequestAuthenticator > requestAuthenticator=nullptr, std::string messageBody="", long connectionTimeoutMs=DEFAULT_CONNECTION_TIMEOUT_MS, long timeoutMs=DEFAULT_TIMEOUT_MS)
Constructs new instance.
Definition HTTPRequest.h:39
long getTimeoutMs() const
Returns total time out in ms, 0 if the request does not time out.
Definition HTTPRequest.h:92
const std::shared_ptr< const tenduke::http::HTTPRequestAuthenticator > & getRequestAuthenticator() const
Returns HTTP request authenticator.
Definition HTTPRequest.h:80
HTTPRequest(std::string method, ::tenduke::net::URL url, const std::multimap< std::string, std::string > &headers=std::multimap< std::string, std::string >(), std::shared_ptr< const tenduke::http::HTTPRequestAuthenticator > requestAuthenticator=nullptr, std::string messageBody="", long connectionTimeoutMs=DEFAULT_CONNECTION_TIMEOUT_MS, long timeoutMs=DEFAULT_TIMEOUT_MS)
Constructs new instance.
Definition HTTPRequest.h:39
const std::string & getMethod() const
Returns the method.
Definition HTTPRequest.h:62
const ::tenduke::net::URL getURL() const
Returns the URL.
Definition HTTPRequest.h:68
bool hasBody() const
Checks if request has body.
Definition HTTPRequest.h:98
const std::multimap< std::string, std::string > & getHeaders() const
Returns request headers.
Definition HTTPRequest.h:74
const std::string & getMessageBody() const
Returns the message body.
Definition HTTPRequest.h:56
long getConnectionTimeoutMs() const
Returns connection timeout in ms.
Definition HTTPRequest.h:86
Represents URL.
Definition URL.h:23
HTTP-related services.
Definition BadRequest.h:6
const std::size_t DEFAULT_MAX_RESPONSE_BODY_SIZE
Default maximum size of a response body in bytes (10 MiB).
Definition HTTPRequest.h:21
const long DEFAULT_CONNECTION_TIMEOUT_MS
Default connection time out in milliseconds.
Definition HTTPRequest.h:15
const long DEFAULT_TIMEOUT_MS
Default total time out in milliseconds.
Definition HTTPRequest.h:18
Root for classes, functions and globals of 10Duke C++ Client.
Definition APIRequest.h:4