CppServer
1.0.4.0
C++ Server Library
|
#include <http_request.h>
Public Member Functions | |
HTTPRequest () | |
Initialize an empty HTTP request. More... | |
HTTPRequest (std::string_view method, std::string_view url, std::string_view protocol="HTTP/1.1") | |
Initialize a new HTTP request with a given method, URL and protocol. More... | |
HTTPRequest (const HTTPRequest &)=default | |
HTTPRequest (HTTPRequest &&)=default | |
~HTTPRequest ()=default | |
HTTPRequest & | operator= (const HTTPRequest &)=default |
HTTPRequest & | operator= (HTTPRequest &&)=default |
bool | empty () const noexcept |
Is the HTTP request empty? More... | |
bool | error () const noexcept |
Is the HTTP request error flag set? More... | |
std::string_view | method () const noexcept |
Get the HTTP request method. More... | |
std::string_view | url () const noexcept |
Get the HTTP request URL. More... | |
std::string_view | protocol () const noexcept |
Get the HTTP request protocol version. More... | |
size_t | headers () const noexcept |
Get the HTTP request headers count. More... | |
std::tuple< std::string_view, std::string_view > | header (size_t i) const noexcept |
Get the HTTP request header by index. More... | |
size_t | cookies () const noexcept |
Get the HTTP request cookies count. More... | |
std::tuple< std::string_view, std::string_view > | cookie (size_t i) const noexcept |
Get the HTTP request cookie by index. More... | |
std::string_view | body () const noexcept |
Get the HTTP request body. More... | |
size_t | body_length () const noexcept |
Get the HTTP request body length. More... | |
const std::string & | cache () const noexcept |
Get the HTTP request cache content. More... | |
std::string | string () const |
Get string from the current HTTP request. More... | |
HTTPRequest & | Clear () |
Clear the HTTP request cache. More... | |
HTTPRequest & | SetBegin (std::string_view method, std::string_view url, std::string_view protocol="HTTP/1.1") |
Set the HTTP request begin with a given method, URL and protocol. More... | |
HTTPRequest & | SetHeader (std::string_view key, std::string_view value) |
Set the HTTP request header. More... | |
HTTPRequest & | SetCookie (std::string_view name, std::string_view value) |
Set the HTTP request cookie. More... | |
HTTPRequest & | AddCookie (std::string_view name, std::string_view value) |
Add the HTTP request cookie. More... | |
HTTPRequest & | SetBody (std::string_view body="") |
Set the HTTP request body. More... | |
HTTPRequest & | SetBodyLength (size_t length) |
Set the HTTP request body length. More... | |
HTTPRequest & | MakeHeadRequest (std::string_view url) |
Make HEAD request. More... | |
HTTPRequest & | MakeGetRequest (std::string_view url) |
Make GET request. More... | |
HTTPRequest & | MakePostRequest (std::string_view url, std::string_view content, std::string_view content_type="text/plain; charset=UTF-8") |
Make POST request. More... | |
HTTPRequest & | MakePutRequest (std::string_view url, std::string_view content, std::string_view content_type="text/plain; charset=UTF-8") |
Make PUT request. More... | |
HTTPRequest & | MakeDeleteRequest (std::string_view url) |
Make DELETE request. More... | |
HTTPRequest & | MakeOptionsRequest (std::string_view url) |
Make OPTIONS request. More... | |
HTTPRequest & | MakeTraceRequest (std::string_view url) |
Make TRACE request. More... | |
void | swap (HTTPRequest &request) noexcept |
Swap two instances. More... | |
Friends | |
class | HTTPSession |
class | HTTPSSession |
std::ostream & | operator<< (std::ostream &os, const HTTPRequest &request) |
Output instance into the given output stream. More... | |
void | swap (HTTPRequest &request1, HTTPRequest &request2) noexcept |
HTTP request.
HTTP request is used to create or process parameters of HTTP protocol request (method, URL, headers, etc).
Not thread-safe.
Definition at line 30 of file http_request.h.
|
inline |
Initialize an empty HTTP request.
Definition at line 37 of file http_request.h.
|
inline |
Initialize a new HTTP request with a given method, URL and protocol.
method | - HTTP method |
url | - Requested URL |
protocol | - Protocol version (default is "HTTP/1.1") |
Definition at line 44 of file http_request.h.
|
default |
|
default |
|
default |
HTTPRequest & CppServer::HTTP::HTTPRequest::AddCookie | ( | std::string_view | name, |
std::string_view | value | ||
) |
Add the HTTP request cookie.
name | - Cookie name |
value | - Cookie value |
Definition at line 155 of file http_request.cpp.
|
inlinenoexcept |
Get the HTTP request body.
Definition at line 72 of file http_request.h.
|
inlinenoexcept |
Get the HTTP request body length.
Definition at line 74 of file http_request.h.
|
inlinenoexcept |
Get the HTTP request cache content.
Definition at line 77 of file http_request.h.
HTTPRequest & CppServer::HTTP::HTTPRequest::Clear | ( | ) |
Clear the HTTP request cache.
Definition at line 41 of file http_request.cpp.
|
noexcept |
Get the HTTP request cookie by index.
Definition at line 30 of file http_request.cpp.
|
inlinenoexcept |
Get the HTTP request cookies count.
Definition at line 68 of file http_request.h.
|
inlinenoexcept |
Is the HTTP request empty?
Definition at line 53 of file http_request.h.
|
inlinenoexcept |
Is the HTTP request error flag set?
Definition at line 55 of file http_request.h.
|
noexcept |
Get the HTTP request header by index.
Definition at line 19 of file http_request.cpp.
|
inlinenoexcept |
Get the HTTP request headers count.
Definition at line 64 of file http_request.h.
HTTPRequest & CppServer::HTTP::HTTPRequest::MakeDeleteRequest | ( | std::string_view | url | ) |
Make DELETE request.
url | - URL to request |
Definition at line 247 of file http_request.cpp.
HTTPRequest & CppServer::HTTP::HTTPRequest::MakeGetRequest | ( | std::string_view | url | ) |
Make GET request.
url | - URL to request |
Definition at line 219 of file http_request.cpp.
HTTPRequest & CppServer::HTTP::HTTPRequest::MakeHeadRequest | ( | std::string_view | url | ) |
Make HEAD request.
url | - URL to request |
Definition at line 211 of file http_request.cpp.
HTTPRequest & CppServer::HTTP::HTTPRequest::MakeOptionsRequest | ( | std::string_view | url | ) |
Make OPTIONS request.
url | - URL to request |
Definition at line 255 of file http_request.cpp.
HTTPRequest & CppServer::HTTP::HTTPRequest::MakePostRequest | ( | std::string_view | url, |
std::string_view | content, | ||
std::string_view | content_type = "text/plain; charset=UTF-8" |
||
) |
Make POST request.
url | - URL to request |
content | - Content |
content_type | - Content type (default is "text/plain; charset=UTF-8") |
Definition at line 227 of file http_request.cpp.
HTTPRequest & CppServer::HTTP::HTTPRequest::MakePutRequest | ( | std::string_view | url, |
std::string_view | content, | ||
std::string_view | content_type = "text/plain; charset=UTF-8" |
||
) |
Make PUT request.
url | - URL to request |
content | - Content |
content_type | - Content type (default is "text/plain; charset=UTF-8") |
Definition at line 237 of file http_request.cpp.
HTTPRequest & CppServer::HTTP::HTTPRequest::MakeTraceRequest | ( | std::string_view | url | ) |
Make TRACE request.
url | - URL to request |
Definition at line 263 of file http_request.cpp.
|
inlinenoexcept |
Get the HTTP request method.
Definition at line 58 of file http_request.h.
|
default |
|
default |
|
inlinenoexcept |
Get the HTTP request protocol version.
Definition at line 62 of file http_request.h.
HTTPRequest & CppServer::HTTP::HTTPRequest::SetBegin | ( | std::string_view | method, |
std::string_view | url, | ||
std::string_view | protocol = "HTTP/1.1" |
||
) |
Set the HTTP request begin with a given method, URL and protocol.
method | - HTTP method |
url | - Requested URL |
protocol | - Protocol version (default is "HTTP/1.1") |
Definition at line 62 of file http_request.cpp.
HTTPRequest & CppServer::HTTP::HTTPRequest::SetBody | ( | std::string_view | body = "" | ) |
Set the HTTP request body.
body | - Body content (default is "") |
Definition at line 174 of file http_request.cpp.
HTTPRequest & CppServer::HTTP::HTTPRequest::SetBodyLength | ( | size_t | length | ) |
Set the HTTP request body length.
length | - Body length |
Definition at line 193 of file http_request.cpp.
HTTPRequest & CppServer::HTTP::HTTPRequest::SetCookie | ( | std::string_view | name, |
std::string_view | value | ||
) |
Set the HTTP request cookie.
name | - Cookie name |
value | - Cookie value |
Definition at line 118 of file http_request.cpp.
HTTPRequest & CppServer::HTTP::HTTPRequest::SetHeader | ( | std::string_view | key, |
std::string_view | value | ||
) |
Set the HTTP request header.
key | - Header key |
value | - Header value |
Definition at line 94 of file http_request.cpp.
|
inline |
Get string from the current HTTP request.
Definition at line 80 of file http_request.h.
|
noexcept |
Swap two instances.
Definition at line 626 of file http_request.cpp.
|
inlinenoexcept |
Get the HTTP request URL.
Definition at line 60 of file http_request.h.
|
friend |
Definition at line 32 of file http_request.h.
|
friend |
Definition at line 33 of file http_request.h.
|
friend |
Output instance into the given output stream.
Definition at line 610 of file http_request.cpp.
|
friend |
Definition at line 173 of file http_request.h.