PTLib
Version 2.10.4
|
This object describes a HyperText Transport Protocol resource. More...
#include <http.h>
Public Member Functions | |
virtual | ~PHTTPResource () |
const PURL & | GetURL () const |
Get the URL for this resource. | |
const PString & | GetContentType () const |
Get the current content type for the resource. | |
PHTTPAuthority * | GetAuthority () const |
Get the current authority for the resource. | |
void | SetAuthority (const PHTTPAuthority &auth) |
Set the current authority for the resource. | |
void | ClearAuthority () |
Set the current authority for the resource to unrestricted. | |
DWORD | GetHitCount () const |
Get the current hit count for the resource. | |
void | ClearHitCount () |
virtual PBoolean | OnGET (PHTTPServer &server, const PURL &url, const PMIMEInfo &info, const PHTTPConnectionInfo &conInfo) |
Handle the GET command passed from the HTTP socket. | |
virtual PBoolean | OnGETData (PHTTPServer &server, const PURL &url, const PHTTPConnectionInfo &connectInfo, PHTTPRequest &request) |
Send the data associated with a GET command. | |
virtual PBoolean | OnHEAD (PHTTPServer &server, const PURL &url, const PMIMEInfo &info, const PHTTPConnectionInfo &conInfo) |
Handle the HEAD command passed from the HTTP socket. | |
virtual PBoolean | OnPOST (PHTTPServer &server, const PURL &url, const PMIMEInfo &info, const PStringToString &data, const PHTTPConnectionInfo &conInfo) |
Handle the POST command passed from the HTTP socket. | |
virtual PBoolean | OnPOSTData (PHTTPRequest &request, const PStringToString &data) |
Send the data associated with a POST command. | |
virtual PBoolean | IsModifiedSince (const PTime &when) |
Check to see if the resource has been modified since the date specified. | |
virtual PBoolean | GetExpirationDate (PTime &when) |
Get a block of data (eg HTML) that the resource contains. | |
virtual PHTTPRequest * | CreateRequest (const PURL &url, const PMIMEInfo &inMIME, const PMultiPartList &multipartFormInfo, PHTTPServer &socket) |
Create a new request block for this type of resource. | |
virtual PBoolean | LoadHeaders (PHTTPRequest &request)=0 |
Get the headers for block of data (eg HTML) that the resource contains. | |
virtual void | SendData (PHTTPRequest &request) |
Send the data associated with a command. | |
virtual PBoolean | LoadData (PHTTPRequest &request, PCharArray &data) |
Get a block of data that the resource contains. | |
virtual PString | LoadText (PHTTPRequest &request) |
Get a block of text data (eg HTML) that the resource contains. | |
virtual void | OnLoadedText (PHTTPRequest &request, PString &text) |
This is called after the text has been loaded and may be used to customise or otherwise mangle a loaded piece of text. | |
virtual PBoolean | Post (PHTTPRequest &request, const PStringToString &data, PHTML &replyMessage) |
Get a block of data (eg HTML) that the resource contains. | |
Protected Member Functions | |
PHTTPResource (const PURL &url) | |
PHTTPResource (const PURL &url, const PHTTPAuthority &auth) | |
PHTTPResource (const PURL &url, const PString &contentType) | |
PHTTPResource (const PURL &url, const PString &contentType, const PHTTPAuthority &auth) | |
virtual PBoolean | CheckAuthority (PHTTPServer &server, const PHTTPRequest &request, const PHTTPConnectionInfo &conInfo) |
See if the resource is authorised given the mime info. | |
virtual PBoolean | OnGETOrHEAD (PHTTPServer &server, const PURL &url, const PMIMEInfo &info, const PHTTPConnectionInfo &conInfo, PBoolean isGet) |
common code for GET and HEAD commands | |
Static Protected Member Functions | |
static PBoolean | CheckAuthority (PHTTPAuthority &authority, PHTTPServer &server, const PHTTPRequest &request, const PHTTPConnectionInfo &connectInfo) |
Protected Attributes | |
PURL | baseURL |
Base URL for the resource, may accept URLS with a longer hierarchy. | |
PString | contentType |
MIME content type for the resource. | |
PHTTPAuthority * | authority |
Authorisation method for the resource. | |
volatile DWORD | hitCount |
COunt of number of times resource was accessed. |
This object describes a HyperText Transport Protocol resource.
A tree of these resources are available to the PHTTPServer
class.
PHTTPResource::PHTTPResource | ( | const PURL & | url | ) | [protected] |
url | Name of the resource in URL space. |
PHTTPResource::PHTTPResource | ( | const PURL & | url, |
const PHTTPAuthority & | auth | ||
) | [protected] |
url | Name of the resource in URL space. |
auth | Authorisation for the resource. |
PHTTPResource::PHTTPResource | ( | const PURL & | url, |
const PString & | contentType | ||
) | [protected] |
url | Name of the resource in URL space. |
contentType | MIME content type for the resource. |
PHTTPResource::PHTTPResource | ( | const PURL & | url, |
const PString & | contentType, | ||
const PHTTPAuthority & | auth | ||
) | [protected] |
url | Name of the resource in URL space. |
contentType | MIME content type for the resource. |
auth | Authorisation for the resource. |
virtual PHTTPResource::~PHTTPResource | ( | ) | [virtual] |
virtual PBoolean PHTTPResource::CheckAuthority | ( | PHTTPServer & | server, |
const PHTTPRequest & | request, | ||
const PHTTPConnectionInfo & | conInfo | ||
) | [protected, virtual] |
See if the resource is authorised given the mime info.
server | Server to send response to. |
request | Information on this request. |
conInfo | Information on the connection |
Reimplemented in PHTTPDirectory.
static PBoolean PHTTPResource::CheckAuthority | ( | PHTTPAuthority & | authority, |
PHTTPServer & | server, | ||
const PHTTPRequest & | request, | ||
const PHTTPConnectionInfo & | connectInfo | ||
) | [static, protected] |
void PHTTPResource::ClearAuthority | ( | ) |
Set the current authority for the resource to unrestricted.
void PHTTPResource::ClearHitCount | ( | ) | [inline] |
References hitCount.
virtual PHTTPRequest* PHTTPResource::CreateRequest | ( | const PURL & | url, |
const PMIMEInfo & | inMIME, | ||
const PMultiPartList & | multipartFormInfo, | ||
PHTTPServer & | socket | ||
) | [virtual] |
Create a new request block for this type of resource.
The default behaviour is to create a new PHTTPRequest instance.
url | Universal Resource Locator for document. |
inMIME | Extra MIME information in command. |
multipartFormInfo | additional information for multi-part posts |
socket | socket used for request |
Reimplemented in PHTTPDirectory, and PHTTPFile.
PHTTPAuthority* PHTTPResource::GetAuthority | ( | ) | const [inline] |
Get the current authority for the resource.
References authority.
const PString& PHTTPResource::GetContentType | ( | ) | const [inline] |
Get the current content type for the resource.
References contentType.
virtual PBoolean PHTTPResource::GetExpirationDate | ( | PTime & | when | ) | [virtual] |
Get a block of data (eg HTML) that the resource contains.
when | Time that the resource expires |
Reimplemented in PServiceHTTPDirectory, PServiceHTTPFile, PServiceHTTPString, PConfigSectionsPage, and PConfigPage.
DWORD PHTTPResource::GetHitCount | ( | ) | const [inline] |
Get the current hit count for the resource.
This is the total number of times the resource was asked for by a remote client.
References hitCount.
const PURL& PHTTPResource::GetURL | ( | ) | const [inline] |
virtual PBoolean PHTTPResource::IsModifiedSince | ( | const PTime & | when | ) | [virtual] |
Check to see if the resource has been modified since the date specified.
when | Time to see if modified later than |
virtual PBoolean PHTTPResource::LoadData | ( | PHTTPRequest & | request, |
PCharArray & | data | ||
) | [virtual] |
Get a block of data that the resource contains.
The default behaviour is to call the LoadText()
function and if successful, call the OnLoadedText()
function.
request | Information on this request. |
data | Data used in reply. |
Reimplemented in PHTTPTailFile, and PHTTPFile.
virtual PBoolean PHTTPResource::LoadHeaders | ( | PHTTPRequest & | request | ) | [pure virtual] |
Get the headers for block of data (eg HTML) that the resource contains.
This will fill in all the fields of the outMIME
parameter required by the resource and return the status for the load.
request | Information on this request. |
Implemented in PHTTPDirectory, PHTTPTailFile, PHTTPFile, PHTTPString, PSOAPServerResource, and PXMLRPCServerResource.
virtual PString PHTTPResource::LoadText | ( | PHTTPRequest & | request | ) | [virtual] |
Get a block of text data (eg HTML) that the resource contains.
The default behaviour is to assert, one of LoadText()
or LoadData()
functions must be overridden for correct operation.
request | Information on this request. |
Reimplemented in PHTTPDirectory, PHTTPFile, PHTTPString, PServiceHTTPString, and PRegisterPage.
virtual PBoolean PHTTPResource::OnGET | ( | PHTTPServer & | server, |
const PURL & | url, | ||
const PMIMEInfo & | info, | ||
const PHTTPConnectionInfo & | conInfo | ||
) | [virtual] |
Handle the GET command passed from the HTTP socket.
The default action is to check the authorisation for the resource and call the virtuals LoadHeaders()
and OnGETData()
to get a resource to be sent to the socket.
server | HTTP server that received the request |
url | Universal Resource Locator for document. |
info | Extra MIME information in command. |
conInfo | HTTP connection information |
virtual PBoolean PHTTPResource::OnGETData | ( | PHTTPServer & | server, |
const PURL & | url, | ||
const PHTTPConnectionInfo & | connectInfo, | ||
PHTTPRequest & | request | ||
) | [virtual] |
Send the data associated with a GET command.
The default action calls SendData()
.
server | HTTP server that received the request |
url | Universal Resource Locator for document |
connectInfo | HTTP connection information |
request | request state information |
virtual PBoolean PHTTPResource::OnGETOrHEAD | ( | PHTTPServer & | server, |
const PURL & | url, | ||
const PMIMEInfo & | info, | ||
const PHTTPConnectionInfo & | conInfo, | ||
PBoolean | isGet | ||
) | [protected, virtual] |
common code for GET and HEAD commands
server | HTTP server that received the request |
url | Universal Resource Locator for document. |
info | Extra MIME information in command. |
conInfo | Connection information |
isGet | Flag indicating is GET or HEAD |
virtual PBoolean PHTTPResource::OnHEAD | ( | PHTTPServer & | server, |
const PURL & | url, | ||
const PMIMEInfo & | info, | ||
const PHTTPConnectionInfo & | conInfo | ||
) | [virtual] |
Handle the HEAD command passed from the HTTP socket.
The default action is to check the authorisation for the resource and call the virtual LoadHeaders()
to get the header information to be sent to the socket.
server | HTTP server that received the request |
url | Universal Resource Locator for document. |
info | Extra MIME information in command. |
conInfo | HTTP connection information |
virtual void PHTTPResource::OnLoadedText | ( | PHTTPRequest & | request, |
PString & | text | ||
) | [virtual] |
This is called after the text has been loaded and may be used to customise or otherwise mangle a loaded piece of text.
Typically this is used with HTML responses.
The default action for this function is to do nothing.
request | Information on this request. |
text | Data used in reply. |
Reimplemented in PHTTPConfigSectionList, PHTTPConfig, PHTTPForm, PServiceHTTPDirectory, PServiceHTTPFile, PRegisterPage, PConfigSectionsPage, and PConfigPage.
virtual PBoolean PHTTPResource::OnPOST | ( | PHTTPServer & | server, |
const PURL & | url, | ||
const PMIMEInfo & | info, | ||
const PStringToString & | data, | ||
const PHTTPConnectionInfo & | conInfo | ||
) | [virtual] |
Handle the POST command passed from the HTTP socket.
The default action is to check the authorisation for the resource and call the virtual Post()
function to handle the data being received.
server | HTTP server that received the request |
url | Universal Resource Locator for document. |
info | Extra MIME information in command. |
data | Variables in the POST data. |
conInfo | HTTP connection information |
Reimplemented in PConfigSectionsPage, and PConfigPage.
virtual PBoolean PHTTPResource::OnPOSTData | ( | PHTTPRequest & | request, |
const PStringToString & | data | ||
) | [virtual] |
Send the data associated with a POST command.
The default action calls Post()
.
request | request information |
data | Variables in the POST data. |
Reimplemented in PSOAPServerResource, and PXMLRPCServerResource.
virtual PBoolean PHTTPResource::Post | ( | PHTTPRequest & | request, |
const PStringToString & | data, | ||
PHTML & | replyMessage | ||
) | [virtual] |
Get a block of data (eg HTML) that the resource contains.
The default action for this function is to do nothing and return success.
request | Information on this request. |
data | Variables in the POST data. |
replyMessage | Reply message for post. |
Reimplemented in PHTTPConfigSectionList, PHTTPConfig, PHTTPForm, PRegisterPage, PConfigSectionsPage, and PConfigPage.
virtual void PHTTPResource::SendData | ( | PHTTPRequest & | request | ) | [virtual] |
Send the data associated with a command.
The default action is to call the virtual LoadData()
to get a resource to be sent to the socket.
request | information for this request |
void PHTTPResource::SetAuthority | ( | const PHTTPAuthority & | auth | ) |
Set the current authority for the resource.
auth | authority to set |
PHTTPAuthority* PHTTPResource::authority [protected] |
Authorisation method for the resource.
Referenced by GetAuthority().
PURL PHTTPResource::baseURL [protected] |
Base URL for the resource, may accept URLS with a longer hierarchy.
Referenced by GetURL().
PString PHTTPResource::contentType [protected] |
MIME content type for the resource.
Referenced by GetContentType().
volatile DWORD PHTTPResource::hitCount [protected] |
COunt of number of times resource was accessed.
Referenced by ClearHitCount(), and GetHitCount().