PTLib  Version 2.18.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PHTTPConfig Class Reference

#include <httpform.h>

Inheritance diagram for PHTTPConfig:
Collaboration diagram for PHTTPConfig:

Public Member Functions

 PHTTPConfig (const PURL &url, const PString &section)
 
 PHTTPConfig (const PURL &url, const PString &section, const PHTTPAuthority &auth)
 
 PHTTPConfig (const PURL &url, const PString &section, const PString &html)
 
 PHTTPConfig (const PURL &url, const PString &section, const PString &html, const PHTTPAuthority &auth)
 
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...
 
void LoadFromConfig ()
 Load all of the values for the resource from the configuration. More...
 
void LoadFromJSON (const PJSON &json)
 Set the value of the JSON to the pages fields. More...
 
void SaveToJSON (PJSON &json)
 Set the value of the pages fields into the JSON. More...
 
const PStringGetConfigSection () const
 Get the configuration file section that the page will alter. More...
 
void SetConfigSection (const PString &sect)
 
PHTTPFieldAddSectionField (PHTTPField *sectionFld, const char *prefix=NULL, const char *suffix=NULL)
 Add a field that will determine the name opf the secontion into which the other fields are to be added as keys. More...
 
void AddNewKeyFields (PHTTPField *keyFld, PHTTPField *valFld)
 Add fields to the HTTP form for adding a new key to the config file section. More...
 
bool AddBooleanField (const char *name, bool defaultValue=false, const char *help=NULL)
 Add a boolean field. More...
 
int AddIntegerField (const char *name, int low, int high, int defaultValue=0, const char *units=NULL, const char *help=NULL)
 Add an integer field. More...
 
PString AddStringField (const char *name, PINDEX maxLength, const char *defaultValue=NULL, const char *help=NULL, int rows=0, int columns=0)
 Add a string field. More...
 
PStringArray AddStringArrayField (const char *name, bool sorted, PINDEX maxLength, const PStringArray &defaultValues, const char *help=NULL, int rows=0, int columns=0)
 Add a string array field. More...
 
PString AddSelectField (const char *name, const PStringArray &valueArray, const char *defaultValue=NULL, const char *help=NULL, bool enumeration=false)
 Add a string field. More...
 
PStringArray AddSelectArrayField (const char *name, bool sorted, const PStringArray &defaultValues, const PStringArray &possibleValues, const char *help=NULL, bool enumeration=false)
 Add a string array field. More...
 
- Public Member Functions inherited from PHTTPForm
 PHTTPForm (const PURL &url)
 
 PHTTPForm (const PURL &url, const PHTTPAuthority &auth)
 
 PHTTPForm (const PURL &url, const PString &html)
 
 PHTTPForm (const PURL &url, const PString &html, const PHTTPAuthority &auth)
 
PHTTPFieldAdd (PHTTPField *fld)
 
void RemoveAllFields ()
 
void BuildHTML (const char *heading)
 
void BuildHTML (const PString &heading)
 
void BuildHTML (PHTML &html, BuildOptions option=CompleteHTML)
 
- Public Member Functions inherited from PHTTPString
 PHTTPString (const PURL &url)
 Contruct a new simple string resource for the HTTP space. More...
 
 PHTTPString (const PURL &url, const PHTTPAuthority &auth)
 
 PHTTPString (const PURL &url, const PString &str)
 
 PHTTPString (const PURL &url, const PString &str, const PString &contentType)
 
 PHTTPString (const PURL &url, const PString &str, const PHTTPAuthority &auth)
 
 PHTTPString (const PURL &url, const PString &str, const PString &contentType, const PHTTPAuthority &auth)
 
virtual PBoolean LoadHeaders (PHTTPRequest &request)
 Get the headers for block of data (eg HTML) that the resource contains. More...
 
virtual PString LoadText (PHTTPRequest &request)
 Get a block of text data (eg HTML) that the resource contains. More...
 
const PStringGetString ()
 Get the string for this resource. More...
 
void SetString (const PString &str)
 Set the string to be returned by this resource. More...
 
- Public Member Functions inherited from PHTTPResource
virtual ~PHTTPResource ()
 
const PURLGetURL () const
 Get the URL for this resource. More...
 
PString GetHotLink () const
 Get relative hot link for this resouce. More...
 
const PStringGetContentType () const
 Get the current content type for the resource. More...
 
PHTTPAuthorityGetAuthority () 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 PHTTPRequestCreateRequest (const PURL &url, const PMIMEInfo &inMIME, const PMultiPartList &multipartFormInfo, PHTTPServer &socket)
 Create a new request block for this type of resource. 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...
 
- Public Member Functions inherited from PObject
__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 PObjectPTraceObjectInstance () const
 
virtual PObjectClone () 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 Attributes

PString m_section
 
PString m_sectionPrefix
 
PString m_sectionSuffix
 
PHTTPFieldm_sectionField
 
PHTTPFieldm_keyField
 
PHTTPFieldm_valField
 
- Protected Attributes inherited from PHTTPForm
PHTTPCompositeField m_fields
 
PStringSet m_fieldNames
 
- Protected Attributes inherited from PHTTPString
PString m_string
 
- Protected Attributes inherited from PHTTPResource
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...
 
PHTTPAuthoritym_authority
 Authorisation method for the resource. More...
 
atomic< unsigned > m_hitCount
 Count of number of times resource was accessed. More...
 
- Protected Attributes inherited from PObject
unsigned m_traceContextIdentifier
 

Additional Inherited Members

- Public Types inherited from PHTTPForm
enum  BuildOptions { CompleteHTML, InsertIntoForm, InsertIntoHTML }
 
- Public Types inherited from PObject
enum  Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }
 Result of the comparison operation performed by the Compare() function. More...
 
- Static Public Member Functions inherited from PObject
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 PObjectPTraceObjectInstance (const char *)
 
static __inline const PObjectPTraceObjectInstance (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...
 
- Protected Member Functions inherited from PHTTPResource
 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)
 
- Protected Member Functions inherited from PObject
 PObject ()
 Constructor for PObject, made protected so cannot ever create one on its own. More...
 
- Static Protected Member Functions inherited from PHTTPResource
static PBoolean CheckAuthority (PHTTPAuthority &authority, PHTTPServer &server, const PHTTPRequest &request, const PHTTPConnectionInfo &connectInfo)
 

Constructor & Destructor Documentation

PHTTPConfig::PHTTPConfig ( const PURL url,
const PString section 
)
PHTTPConfig::PHTTPConfig ( const PURL url,
const PString section,
const PHTTPAuthority auth 
)
PHTTPConfig::PHTTPConfig ( const PURL url,
const PString section,
const PString html 
)
PHTTPConfig::PHTTPConfig ( const PURL url,
const PString section,
const PString html,
const PHTTPAuthority auth 
)

Member Function Documentation

bool PHTTPConfig::AddBooleanField ( const char *  name,
bool  defaultValue = false,
const char *  help = NULL 
)

Add a boolean field.

Returns current value from PConfig, using defaultValue for first time.

int PHTTPConfig::AddIntegerField ( const char *  name,
int  low,
int  high,
int  defaultValue = 0,
const char *  units = NULL,
const char *  help = NULL 
)

Add an integer field.

Returns current value from PConfig, using defaultValue for first time.

void PHTTPConfig::AddNewKeyFields ( PHTTPField keyFld,
PHTTPField valFld 
)

Add fields to the HTTP form for adding a new key to the config file section.

Parameters
keyFldField for the key to be added.
valFldField for the value of the key yto be added.
PHTTPField* PHTTPConfig::AddSectionField ( PHTTPField sectionFld,
const char *  prefix = NULL,
const char *  suffix = NULL 
)

Add a field that will determine the name opf the secontion into which the other fields are to be added as keys.

The section is not created and and error generated if the section already exists.

Parameters
sectionFldField to set as the section name
prefixString to attach before the field value
suffixString to attach after the field value
PStringArray PHTTPConfig::AddSelectArrayField ( const char *  name,
bool  sorted,
const PStringArray defaultValues,
const PStringArray possibleValues,
const char *  help = NULL,
bool  enumeration = false 
)

Add a string array field.

Returns current value from PConfig, using defaultValue for first time.

PString PHTTPConfig::AddSelectField ( const char *  name,
const PStringArray valueArray,
const char *  defaultValue = NULL,
const char *  help = NULL,
bool  enumeration = false 
)

Add a string field.

Returns current value from PConfig, using defaultValue for first time.

PStringArray PHTTPConfig::AddStringArrayField ( const char *  name,
bool  sorted,
PINDEX  maxLength,
const PStringArray defaultValues,
const char *  help = NULL,
int  rows = 0,
int  columns = 0 
)

Add a string array field.

Returns current value from PConfig, using defaultValue for first time.

PString PHTTPConfig::AddStringField ( const char *  name,
PINDEX  maxLength,
const char *  defaultValue = NULL,
const char *  help = NULL,
int  rows = 0,
int  columns = 0 
)

Add a string field.

Returns current value from PConfig, using defaultValue for first time.

const PString& PHTTPConfig::GetConfigSection ( ) const
inline

Get the configuration file section that the page will alter.

Returns
String for config file section.

References m_section.

void PHTTPConfig::LoadFromConfig ( )

Load all of the values for the resource from the configuration.

void PHTTPConfig::LoadFromJSON ( const PJSON json)

Set the value of the JSON to the pages fields.

virtual void PHTTPConfig::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.

Parameters
requestInformation on this request.
textData used in reply.

Reimplemented from PHTTPForm.

Reimplemented in PRegisterPage, and PConfigPage.

virtual PBoolean PHTTPConfig::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.

Returns
true if the connection may persist, false if the connection must close
Parameters
requestInformation on this request.
dataVariables in the POST data.
replyMessageReply message for post.

Reimplemented from PHTTPForm.

Reimplemented in PRegisterPage, and PConfigPage.

void PHTTPConfig::SaveToJSON ( PJSON json)

Set the value of the pages fields into the JSON.

void PHTTPConfig::SetConfigSection ( const PString sect)
inline
Parameters
sectNew section for the config page.

References m_section.

Member Data Documentation

PHTTPField* PHTTPConfig::m_keyField
protected
PString PHTTPConfig::m_section
protected
PHTTPField* PHTTPConfig::m_sectionField
protected
PString PHTTPConfig::m_sectionPrefix
protected
PString PHTTPConfig::m_sectionSuffix
protected
PHTTPField* PHTTPConfig::m_valField
protected

The documentation for this class was generated from the following file: