Public Types | |
typedef boost::shared_ptr< HttpResponse > | HttpResponsePtr |
The return type of calling the send function. | |
Public Member Functions | |
void | addHeader (const SmartUtil::tstring &header) |
Adds up an HTTP header. | |
HttpRequest (const std::string &connectionString, const SmartUtil::tstring &contentType, const std::string &port, unsigned int timeout) | |
Parses the host and path automatically and adds up the parameters. | |
HttpRequest (const std::string &host, const SmartUtil::tstring &postUrl, const SmartUtil::tstring &contentType, const std::string &port, unsigned int timeout) | |
Constructor creating an HTTP request. | |
HttpResponsePtr | send (const SmartUtil::tstring &requestContent) |
Actually sends the request and returns the response in a HttpResponse object. |
Class is tightly coupled with HttpResponse since the return value of making an HTTP request is an HttpResponse Use the constructor to create an object, add up some custom headers (or don't) and then use the send function to send the request and use the returned HttpResponse to parse your return value.
HttpRequest | ( | const std::string & | host, | |
const SmartUtil::tstring & | postUrl, | |||
const SmartUtil::tstring & | contentType, | |||
const std::string & | port, | |||
unsigned int | timeout | |||
) |
Constructor creating an HTTP request.
The host should be e.g. "www.google.com" or "localhost" and the postUrl should be e.g. "/MyApplication/default.aspx" or something. For most HTTP requests the port should be 80. The content type is the type of your request, e.g. for a SOAP calling this could be "text/xml" The timeout value defines how long time the request will wait after sending the request before it "gives up" getting a return value and raises an exception.
void addHeader | ( | const SmartUtil::tstring & | header | ) |
Adds up an HTTP header.
By default only the "POST", "Host:", "Content-Length:" and the "Content-Type:" headers are included. If you need custom headers then use this function to add them up!
HttpRequest::HttpResponsePtr send | ( | const SmartUtil::tstring & | requestContent | ) |
Actually sends the request and returns the response in a HttpResponse object.
If the timeout periode elapses and the server is still unresponsive (the socket still isn't ready for receiving data) an exception will be raised.