#include <http.h>
Inheritance diagram for PHTTPClient:
Public Member Functions | |
PHTTPClient () | |
Create a new HTTP client channel. | |
PHTTPClient (const PString &userAgentName) | |
int | ExecuteCommand (Commands cmd, const PURL &url, PMIMEInfo &outMIME, const PString &dataBody, PMIMEInfo &replyMime, BOOL persist=TRUE) |
int | ExecuteCommand (const PString &cmdName, const PURL &url, PMIMEInfo &outMIME, const PString &dataBody, PMIMEInfo &replyMime, BOOL persist=TRUE) |
BOOL | WriteCommand (Commands cmd, const PString &url, PMIMEInfo &outMIME, const PString &dataBody) |
Write a HTTP command to server. | |
BOOL | WriteCommand (const PString &cmdName, const PString &url, PMIMEInfo &outMIME, const PString &dataBody) |
BOOL | ReadResponse (PMIMEInfo &replyMIME) |
Read a response from the server. | |
BOOL | ReadContentBody (PMIMEInfo &replyMIME, PBYTEArray &body) |
Read the body of the HTTP command. | |
BOOL | ReadContentBody (PMIMEInfo &replyMIME, PString &body) |
BOOL | GetTextDocument (const PURL &url, PString &document, BOOL persist=TRUE) |
BOOL | GetDocument (const PURL &url, PMIMEInfo &outMIME, PMIMEInfo &replyMIME, BOOL persist=TRUE) |
BOOL | GetHeader (const PURL &url, PMIMEInfo &outMIME, PMIMEInfo &replyMIME, BOOL persist=TRUE) |
BOOL | PostData (const PURL &url, PMIMEInfo &outMIME, const PString &data, PMIMEInfo &replyMIME, BOOL persist=TRUE) |
BOOL | PostData (const PURL &url, PMIMEInfo &outMIME, const PString &data, PMIMEInfo &replyMIME, PString &replyBody, BOOL persist=TRUE) |
Protected Member Functions | |
BOOL | AssureConnect (const PURL &url, PMIMEInfo &outMIME) |
BOOL | InternalReadContentBody (PMIMEInfo &replyMIME, PAbstractArray &body) |
Protected Attributes | |
PString | userAgentName |
When acting as a client, the procedure is to make the connection to a remote server, then to retrieve a document using the following procedure:
PHTTPSocket web("webserver");
if (web.IsOpen()) {
PINDEX len;
if (web.GetDocument("http://www.someone.com/somewhere/url", len)) {
PString html = web.ReadString(len);
if (!html.IsEmpty())
ProcessHTML(html);
}
else
PError << "Could not get page." << endl;
}
else
PError << "HTTP conection failed." << endl;
PHTTPClient::PHTTPClient | ( | ) |
Create a new HTTP client channel.
PHTTPClient::PHTTPClient | ( | const PString & | userAgentName | ) |
int PHTTPClient::ExecuteCommand | ( | Commands | cmd, | |
const PURL & | url, | |||
PMIMEInfo & | outMIME, | |||
const PString & | dataBody, | |||
PMIMEInfo & | replyMime, | |||
BOOL | persist = TRUE | |||
) |
Send a command and wait for the response header (including MIME fields). Note that a body may still be on its way even if lasResponseCode is not 200!
int PHTTPClient::ExecuteCommand | ( | const PString & | cmdName, | |
const PURL & | url, | |||
PMIMEInfo & | outMIME, | |||
const PString & | dataBody, | |||
PMIMEInfo & | replyMime, | |||
BOOL | persist = TRUE | |||
) |
BOOL PHTTPClient::WriteCommand | ( | Commands | cmd, | |
const PString & | url, | |||
PMIMEInfo & | outMIME, | |||
const PString & | dataBody | |||
) |
Write a HTTP command to server.
BOOL PHTTPClient::WriteCommand | ( | const PString & | cmdName, | |
const PString & | url, | |||
PMIMEInfo & | outMIME, | |||
const PString & | dataBody | |||
) |
BOOL PHTTPClient::ReadResponse | ( | PMIMEInfo & | replyMIME | ) |
Read a response from the server.
BOOL PHTTPClient::ReadContentBody | ( | PMIMEInfo & | replyMIME, | |
PBYTEArray & | body | |||
) |
Read the body of the HTTP command.
Get the document specified by the URL.
url | Universal Resource Locator for document. |
document | Body read |
persist | if TRUE, enable HTTP persistence |
BOOL PHTTPClient::GetDocument | ( | const PURL & | url, | |
PMIMEInfo & | outMIME, | |||
PMIMEInfo & | replyMIME, | |||
BOOL | persist = TRUE | |||
) |
Get the document specified by the URL.
url | Universal Resource Locator for document. |
outMIME | MIME info in request |
replyMIME | MIME info in response |
persist | if TRUE, enable HTTP persistence |
BOOL PHTTPClient::GetHeader | ( | const PURL & | url, | |
PMIMEInfo & | outMIME, | |||
PMIMEInfo & | replyMIME, | |||
BOOL | persist = TRUE | |||
) |
Get the header for the document specified by the URL.
url | Universal Resource Locator for document. |
outMIME | MIME info in request |
replyMIME | MIME info in response |
persist | if TRUE, enable HTTP persistence |
BOOL PHTTPClient::PostData | ( | const PURL & | url, | |
PMIMEInfo & | outMIME, | |||
const PString & | data, | |||
PMIMEInfo & | replyMIME, | |||
BOOL | persist = TRUE | |||
) |
Post the data specified to the URL.
url | Universal Resource Locator for document. |
outMIME | MIME info in request |
data | Information posted to the HTTP server. |
replyMIME | MIME info in response |
persist | if TRUE, enable HTTP persistence |
BOOL PHTTPClient::PostData | ( | const PURL & | url, | |
PMIMEInfo & | outMIME, | |||
const PString & | data, | |||
PMIMEInfo & | replyMIME, | |||
PString & | replyBody, | |||
BOOL | persist = TRUE | |||
) |
Post the data specified to the URL.
url | Universal Resource Locator for document. |
outMIME | MIME info in request |
data | Information posted to the HTTP server. |
replyMIME | MIME info in response |
replyBody | Body of response |
persist | if TRUE, enable HTTP persistence |
BOOL PHTTPClient::InternalReadContentBody | ( | PMIMEInfo & | replyMIME, | |
PAbstractArray & | body | |||
) | [protected] |
PString PHTTPClient::userAgentName [protected] |