PTLib
Version 2.18.8
|
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. More... | |
PString | GetHotLink () const |
Get relative hot link for this resouce. More... | |
const PString & | GetContentType () const |
Get the current content type for the resource. More... | |
PHTTPAuthority * | GetAuthority () const |
Get the current authority for the resource. More... | |
void | SetAuthority (const PHTTPAuthority &auth) |
Set the current authority for the resource. More... | |
void | ClearAuthority () |
Set the current authority for the resource to unrestricted. More... | |
DWORD | GetHitCount () const |
Get the current hit count for the resource. More... | |
void | ClearHitCount () |
Clear the hit count for the resource. More... | |
virtual bool | SupportsWebSocketProtocol (const PString &protocol) const |
Indicate that the web socket protocol is supported by this resource. More... | |
virtual bool | OnWebSocket (PHTTPServer &server, PHTTPConnectionInfo &connectInfo) |
Called when a request indicates a swtch to WebSocket protocol. More... | |
virtual bool | OnGET (PHTTPServer &server, const PHTTPConnectionInfo &conInfo) |
Handle the GET command passed from the HTTP socket. More... | |
virtual PBoolean | OnGETData (PHTTPServer &server, const PURL &url, const PHTTPConnectionInfo &connectInfo, PHTTPRequest &request) |
Send the data associated with a GET command. More... | |
virtual bool | OnHEAD (PHTTPServer &server, const PHTTPConnectionInfo &conInfo) |
Handle the HEAD command passed from the HTTP socket. More... | |
virtual bool | OnPOST (PHTTPServer &server, const PHTTPConnectionInfo &conInfo) |
Handle the POST command passed from the HTTP socket. More... | |
virtual PBoolean | OnPOSTData (PHTTPRequest &request, const PStringToString &data) |
Send the data associated with a POST command. More... | |
virtual PBoolean | IsModifiedSince (const PTime &when) |
Check to see if the resource has been modified since the date specified. More... | |
virtual PBoolean | GetExpirationDate (PTime &when) |
Get a block of data (eg HTML) that the resource contains. More... | |
virtual PHTTPRequest * | CreateRequest (const PURL &url, const PMIMEInfo &inMIME, const PMultiPartList &multipartFormInfo, PHTTPServer &socket) |
Create a new request block for this type of resource. More... | |
virtual PBoolean | LoadHeaders (PHTTPRequest &request) |
Get the headers for block of data (eg HTML) that the resource contains. More... | |
virtual void | SendData (PHTTPRequest &request) |
Send the data associated with a command. More... | |
virtual PBoolean | LoadData (PHTTPRequest &request, PCharArray &data) |
Get a block of data that the resource contains. More... | |
virtual PString | LoadText (PHTTPRequest &request) |
Get a block of text data (eg HTML) that the resource contains. More... | |
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. More... | |
virtual PBoolean | Post (PHTTPRequest &request, const PStringToString &data, PHTML &replyMessage) |
Get a block of data (eg HTML) that the resource contains. More... | |
![]() | |
__inline unsigned | GetTraceContextIdentifier () const |
Get PTRACE context identifier. More... | |
__inline void | SetTraceContextIdentifier (unsigned id) |
__inline void | SetTraceContextIdentifier (const PObject &obj) |
__inline void | SetTraceContextIdentifier (const PObject *obj) |
__inline void | CopyTraceContextIdentifier (PObject &obj) const |
__inline void | CopyTraceContextIdentifier (PObject *obj) const |
virtual | ~PObject () |
__inline const char * | GetClass () const |
__inline bool | IsClass (const char *name) const |
__inline const PObject * | PTraceObjectInstance () const |
virtual PObject * | Clone () const |
Create a copy of the class on the heap. More... | |
template<class CLS > | |
CLS * | CloneAs () const |
As for Clone() but converts to specified type. More... | |
virtual PINDEX | HashFunction () const |
This function yields a hash value required by the PDictionary class. More... | |
virtual Comparison | Compare (const PObject &obj) const |
Compare the two objects and return their relative rank. More... | |
virtual Comparison | CompareObjectMemoryDirect (const PObject &obj) const |
Determine the byte wise comparison of two objects. More... | |
bool | operator== (const PObject &obj) const |
Compare the two objects. More... | |
bool | operator!= (const PObject &obj) const |
Compare the two objects. More... | |
bool | operator< (const PObject &obj) const |
Compare the two objects. More... | |
bool | operator> (const PObject &obj) const |
Compare the two objects. More... | |
bool | operator<= (const PObject &obj) const |
Compare the two objects. More... | |
bool | operator>= (const PObject &obj) const |
Compare the two objects. More... | |
virtual void | PrintOn (ostream &strm) const |
Output the contents of the object to the stream. More... | |
virtual void | ReadFrom (istream &strm) |
Input the contents of the object from the stream. More... | |
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. More... | |
virtual bool | InternalOnCommand (PHTTPServer &server, const PHTTPConnectionInfo &conInfo, PHTTP::Commands cmd) |
common code for GET and HEAD commands More... | |
P_REMOVE_VIRTUAL (PBoolean, OnGET(PHTTPServer &, const PURL &, const PMIMEInfo &, const PHTTPConnectionInfo &), false) | |
P_REMOVE_VIRTUAL (PBoolean, OnHEAD(PHTTPServer &, const PURL &, const PMIMEInfo &, const PHTTPConnectionInfo &), false) | |
P_REMOVE_VIRTUAL (PBoolean, OnGETOrHEAD(PHTTPServer &, const PURL &, const PMIMEInfo &, const PHTTPConnectionInfo &, PBoolean), false) | |
P_REMOVE_VIRTUAL (PBoolean, OnPOST(PHTTPServer &, const PURL &, const PMIMEInfo &, const PStringToString &, const PHTTPConnectionInfo &), false) | |
![]() | |
PObject () | |
Constructor for PObject, made protected so cannot ever create one on its own. More... | |
Static Protected Member Functions | |
static PBoolean | CheckAuthority (PHTTPAuthority &authority, PHTTPServer &server, const PHTTPRequest &request, const PHTTPConnectionInfo &connectInfo) |
Protected Attributes | |
PURL | m_baseURL |
Base URL for the resource, may accept URLS with a longer hierarchy. More... | |
PString | m_contentType |
MIME content type for the resource. More... | |
PHTTPAuthority * | m_authority |
Authorisation method for the resource. More... | |
atomic< unsigned > | m_hitCount |
Count of number of times resource was accessed. More... | |
![]() | |
unsigned | m_traceContextIdentifier |
Additional Inherited Members | |
![]() | |
enum | Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 } |
Result of the comparison operation performed by the Compare() function. More... | |
![]() | |
static __inline void | CopyTraceContextIdentifier (PObject &to, const PObject &from) |
static __inline void | CopyTraceContextIdentifier (PObject &to, const PObject *from) |
static __inline void | CopyTraceContextIdentifier (PObject *to, const PObject &from) |
static __inline void | CopyTraceContextIdentifier (PObject *to, const PObject *from) |
static __inline const char * | Class () |
static __inline const PObject * | PTraceObjectInstance (const char *) |
static __inline const PObject * | PTraceObjectInstance (const PObject *obj) |
template<typename T > | |
static Comparison | Compare2 (T v1, T v2) |
Compare two types, returning Comparison type. More... | |
static Comparison | InternalCompareObjectMemoryDirect (const PObject *obj1, const PObject *obj2, PINDEX size) |
Internal function caled from CompareObjectMemoryDirect() More... | |
This object describes a HyperText Transport Protocol resource.
A tree of these resources are available to the PHTTPServer
class.
|
protected |
url | Name of the resource in URL space. |
|
protected |
url | Name of the resource in URL space. |
auth | Authorisation for the resource. |
url | Name of the resource in URL space. |
contentType | MIME content type for the resource. |
|
protected |
url | Name of the resource in URL space. |
contentType | MIME content type for the resource. |
auth | Authorisation for the resource. |
|
virtual |
|
protectedvirtual |
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.
|
staticprotected |
void PHTTPResource::ClearAuthority | ( | ) |
Set the current authority for the resource to unrestricted.
|
inline |
Clear the hit count for the resource.
References m_hitCount.
|
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.
|
inline |
Get the current authority for the resource.
References m_authority.
|
inline |
Get the current content type for the resource.
References m_contentType.
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.
|
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 m_hitCount.
|
inline |
Get relative hot link for this resouce.
References PURL::AsString(), m_baseURL, and PURL::PathOnly.
|
inline |
|
protectedvirtual |
common code for GET and HEAD commands
server | HTTP server that received the request |
conInfo | Connection information |
cmd | Command being processed |
Check to see if the resource has been modified since the date specified.
when | Time to see if modified later than |
|
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 |
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. |
Reimplemented in PHTTPDirectory, PHTTPTailFile, PHTTPFile, PHTTPString, PSOAPServerResource, and PXMLRPCServerResource.
|
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, PHTTPServiceProcess::ClearLogPage, PServiceHTTPString, and PRegisterPage.
|
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 |
conInfo | HTTP connection information |
|
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 |
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 |
conInfo | HTTP connection information |
|
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 |
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 |
conInfo | HTTP connection information |
Reimplemented in PConfigSectionsPage, and PConfigPage.
|
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 |
Called when a request indicates a swtch to WebSocket protocol.
This will handle a WebScoket protocol change.
After the start up handshake has completed, if there is a notifier and it is non-null, then the notifier is called. The notifier, may then call connectInfo.ClearWebSocket() if it wishes to return to HTTP mode. That is, ProcessCommand() will return true and the normal persistence rules apply. If ClearWebSocket() is not called then ProcessCommand() will return false.
Note, that the latter case does not mean that the underlying socket is necessarily closed, it could subsequently be disconnected from the PHTTPServer objects and passed to PWebSocket for processing.
server | HTTP server that received the request |
connectInfo | HTTP connection information |
|
protected |
|
protected |
|
protected |
|
protected |
|
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, PHTTPServiceProcess::ClearLogPage, PRegisterPage, PConfigSectionsPage, and PConfigPage.
|
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 |
|
virtual |
Indicate that the web socket protocol is supported by this resource.
protocol | Protocol for web socket |
|
protected |
Authorisation method for the resource.
Referenced by GetAuthority().
|
protected |
Base URL for the resource, may accept URLS with a longer hierarchy.
Referenced by GetHotLink(), and GetURL().
|
protected |
MIME content type for the resource.
Referenced by GetContentType().
|
protected |
Count of number of times resource was accessed.
Referenced by ClearHitCount(), and GetHitCount().