Public Member Functions | |
Request (Method type, std::string url) | |
Method | getMethod () const |
Return the request method. | |
const std::string & | getURL () const |
Return the request URL. | |
Request & | setHeader (const std::string hdr, const std::string value) |
Add an HTTP header to the request. More... | |
Request & | delHeader (const std::string hdr) |
Remove an HTTP header from the request. More... | |
Request & | setBody (char *ptr, size_t length, const std::string content_type) |
Set the request body for the request, starting at the given memory location and counting length bytes. More... | |
Request & | setBody (const std::string data, const std::string content_type) |
Set the request body for the request, using the content of the given data string. More... | |
Request & | setBody (Body &body) |
Set the request body for the request, using the given body object. More... | |
Public Member Functions inherited from mico::http::Message | |
const std::string & | getHeader (const std::string hdr) const |
Return the header with the given name. | |
const Body * | getBody () const |
Return the body of the message. | |
curl_slist * | getCurlHeaders () |
Return the headers in CURL format. | |
void | setCurlHeaders (curl_slist *hdr) |
Set the headers in CURL format. | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Request &req) |
std::istream & | operator>> (std::istream &is, const Request &req) |
size_t | read_callback (void *ptr, size_t size, size_t nmemb, void *request) |
Additional Inherited Members | |
Protected Attributes inherited from mico::http::Message | |
header_map | headers |
Body * | body |
|
inline |
Remove an HTTP header from the request.
Use with care.
Request& mico::http::Request::setBody | ( | char * | ptr, |
size_t | length, | ||
const std::string | content_type | ||
) |
Set the request body for the request, starting at the given memory location and counting length bytes.
The method automatically sets the Content-Type and Content-Length headers accordingly. Only supported by POST and PUT methods. The memory needs to be managed by the caller and is NOT free'd when the request is cleaned up.
Request& mico::http::Request::setBody | ( | const std::string | data, |
const std::string | content_type | ||
) |
Set the request body for the request, using the content of the given data string.
The contents of the string are copied by the request, which takes care of cleaning up the data when it is removed from memory.
Set the request body for the request, using the given body object.
The memory needs to be managed by the caller and is NOT free'd when the request is cleaned up.
|
inline |
Add an HTTP header to the request.
Note that Content-Type and Content-Length are already set by addBody().