#include <ulxr_http_client.h>
Collaboration diagram for ulxr::HttpClient:
Public Member Functions | |
HttpClient (HttpProtocol *prot) | |
Constructs a http client. | |
virtual | ~HttpClient () |
Destroys the http client. | |
void | msgPUT (const Cpp8BitString &msg, const CppString &type, const CppString &resource) |
Puts content into a remote resource. | |
void | filePUT (const CppString &filename, const CppString &type, const CppString &resource) |
Puts content into a remote resource. | |
Cpp8BitString | msgGET (const CppString &resource) |
Gets content from a remote resource. | |
void | fileGET (const CppString &filename, const CppString &resource) |
Gets content from a remote resource. | |
Cpp8BitString | msgPOST (const Cpp8BitString &msg, const CppString &type, const CppString &resource) |
Gets context dependent content from a remote resource. | |
void | doDELETE (const CppString &resource) |
Delete a remote resource. | |
virtual void | setMessageAuthentication (const CppString &user, const CppString &pass) |
Sets username and password for the following transmissions. | |
Protected Member Functions | |
void | sendAuthentication () |
Sends the current authentiocation data over the conenction. | |
int | getHttpStatus () const |
Gets the status value from the response. | |
CppString | getHttpPhrase () const |
Gets the status phrase from the response. | |
CppString | getHttpVersion () const |
Gets the version of the http protocol. | |
virtual void | interpreteHttpHeader () |
Processes all the http headers after the header has been completely read. | |
void | receiveResponse (BodyProcessor &proc) |
Receives a complete response from the server. | |
Private Attributes | |
unsigned | head_status |
CppString | head_phrase |
CppString | head_version |
CppString | http_user |
CppString | http_pass |
HttpProtocol * | protocol |
This implementation only honors the basic http methods PUT, GET, POST and DELETE.
Definition at line 69 of file ulxr_http_client.h.
ulxr::HttpClient::HttpClient | ( | HttpProtocol * | prot | ) |
Constructs a http client.
prot | pointer to an existing connection |
Definition at line 71 of file ulxr_http_client.cpp.
References protocol, ulxr::HttpProtocol::setChunkedTransfer(), ULXR_PCHAR, and ULXR_TRACE.
virtual ulxr::HttpClient::~HttpClient | ( | ) | [inline, virtual] |
void ulxr::HttpClient::msgPUT | ( | const Cpp8BitString & | msg, | |
const CppString & | type, | |||
const CppString & | resource | |||
) |
Puts content into a remote resource.
msg | content to send via http PUT | |
resource | name of the remote resource | |
type | the mime type of the content (e.g. text/html) |
Definition at line 146 of file ulxr_http_client.cpp.
References ulxr::TransportError, ULXR_PCHAR, and ULXR_TRACE.
void ulxr::HttpClient::filePUT | ( | const CppString & | filename, | |
const CppString & | type, | |||
const CppString & | resource | |||
) |
Puts content into a remote resource.
filename | file to send via http PUT | |
type | the mime type of the content (e.g. text/html) | |
resource | name of the remote resource |
Definition at line 172 of file ulxr_http_client.cpp.
References ulxr::getLatin1(), ulxr::SystemError, ulxr::TransportError, ulxr_i18n, ULXR_PCHAR, ULXR_SEND_BUFFER_SIZE, and ULXR_TRACE.
Cpp8BitString ulxr::HttpClient::msgGET | ( | const CppString & | resource | ) |
Gets content from a remote resource.
resource | name of the remote resource |
Definition at line 227 of file ulxr_http_client.cpp.
References ulxr::TransportError, ULXR_PCHAR, and ULXR_TRACE.
Gets content from a remote resource.
filename | filename to store the result from the http GET | |
resource | name of the remote resource |
Definition at line 271 of file ulxr_http_client.cpp.
References ulxr::getLatin1(), ulxr::SystemError, ulxr::TransportError, ulxr_i18n, ULXR_PCHAR, and ULXR_TRACE.
Cpp8BitString ulxr::HttpClient::msgPOST | ( | const Cpp8BitString & | msg, | |
const CppString & | type, | |||
const CppString & | resource | |||
) |
Gets context dependent content from a remote resource.
Usually this is used in web forms where user data is processed.
msg | "selector" for the content to receive via http POST | |
type | the mime type of the content (e.g. text/html) | |
resource | name of the remote resource |
Definition at line 297 of file ulxr_http_client.cpp.
References ulxr::TransportError, ULXR_PCHAR, and ULXR_TRACE.
void ulxr::HttpClient::doDELETE | ( | const CppString & | resource | ) |
Delete a remote resource.
resource | name of the remote resource |
Definition at line 325 of file ulxr_http_client.cpp.
References ulxr::TransportError, ULXR_PCHAR, and ULXR_TRACE.
void ulxr::HttpClient::setMessageAuthentication | ( | const CppString & | user, | |
const CppString & | pass | |||
) | [virtual] |
Sets username and password for the following transmissions.
This makes the next and all following transmission blocks use a simple authentication scheme with a username and password.
user | Username | |
pass | Password |
Definition at line 346 of file ulxr_http_client.cpp.
References ULXR_PCHAR, and ULXR_TRACE.
void ulxr::HttpClient::sendAuthentication | ( | ) | [protected] |
Sends the current authentiocation data over the conenction.
Definition at line 355 of file ulxr_http_client.cpp.
References ULXR_PCHAR, and ULXR_TRACE.
int ulxr::HttpClient::getHttpStatus | ( | ) | const [protected] |
Gets the status value from the response.
Definition at line 363 of file ulxr_http_client.cpp.
CppString ulxr::HttpClient::getHttpPhrase | ( | ) | const [protected] |
Gets the status phrase from the response.
Definition at line 369 of file ulxr_http_client.cpp.
CppString ulxr::HttpClient::getHttpVersion | ( | ) | const [protected] |
Gets the version of the http protocol.
This method return just the numeric part after "/". For example "1.1" instead of "HTTP/1.1".
Definition at line 375 of file ulxr_http_client.cpp.
void ulxr::HttpClient::interpreteHttpHeader | ( | ) | [protected, virtual] |
Processes all the http headers after the header has been completely read.
Definition at line 79 of file ulxr_http_client.cpp.
References ULXR_PCHAR, and ULXR_TRACE.
void ulxr::HttpClient::receiveResponse | ( | BodyProcessor & | proc | ) | [protected] |
Receives a complete response from the server.
proc | pointer to a helper instance to process the message body. |
Definition at line 90 of file ulxr_http_client.cpp.
References ulxr::Protocol::ConnBody, ulxr::Protocol::ConnError, ulxr::Protocol::ConnSwitchToBody, ulxr::TransportError, ulxr_i18n, ULXR_PCHAR, ULXR_RECV_BUFFER_SIZE, and ULXR_TRACE.
unsigned ulxr::HttpClient::head_status [private] |
Definition at line 172 of file ulxr_http_client.h.
CppString ulxr::HttpClient::head_phrase [private] |
Definition at line 173 of file ulxr_http_client.h.
CppString ulxr::HttpClient::head_version [private] |
Definition at line 174 of file ulxr_http_client.h.
CppString ulxr::HttpClient::http_user [private] |
Definition at line 175 of file ulxr_http_client.h.
CppString ulxr::HttpClient::http_pass [private] |
Definition at line 176 of file ulxr_http_client.h.
HttpProtocol* ulxr::HttpClient::protocol [private] |