MICO Platform  1.0.0
 All Classes Namespaces Functions Variables Friends
Public Member Functions | Friends | List of all members
mico::http::Request Class Reference
Inheritance diagram for mico::http::Request:
mico::http::Message

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.
 
RequestsetHeader (const std::string hdr, const std::string value)
 Add an HTTP header to the request. More...
 
RequestdelHeader (const std::string hdr)
 Remove an HTTP header from the request. More...
 
RequestsetBody (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...
 
RequestsetBody (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...
 
RequestsetBody (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 BodygetBody () 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
 
Bodybody
 

Member Function Documentation

Request& mico::http::Request::delHeader ( const std::string  hdr)
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.

Request& mico::http::Request::setBody ( Body body)
inline

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.

Request& mico::http::Request::setHeader ( const std::string  hdr,
const std::string  value 
)
inline

Add an HTTP header to the request.

Note that Content-Type and Content-Length are already set by addBody().


The documentation for this class was generated from the following file: