📄 http.h
字号:
virtual BOOL CheckAuthority(
PHTTPServer & server, ///< Server to send response to.
const PHTTPRequest & request, ///< Information on this request.
const PHTTPConnectionInfo & conInfo ///< Information on the connection
);
static BOOL CheckAuthority(
PHTTPAuthority & authority,
PHTTPServer & server,
const PHTTPRequest & request,
const PHTTPConnectionInfo & connectInfo
);
/** common code for GET and HEAD commands */
virtual BOOL OnGETOrHEAD(
PHTTPServer & server, ///< HTTP server that received the request
const PURL & url, ///< Universal Resource Locator for document.
const PMIMEInfo & info, ///< Extra MIME information in command.
const PHTTPConnectionInfo & conInfo,
BOOL IsGet
);
/// Base URL for the resource, may accept URLS with a longer hierarchy
PURL baseURL;
/// MIME content type for the resource
PString contentType;
/// Authorisation method for the resource
PHTTPAuthority * authority;
/// COunt of number of times resource was accessed.
volatile DWORD hitCount;
};
//////////////////////////////////////////////////////////////////////////////
// PHTTPString
/** This object describes a HyperText Transport Protocol resource which is a
string kept in memory. For instance a pre-calculated HTML string could be
set in this type of resource.
*/
class PHTTPString : public PHTTPResource
{
PCLASSINFO(PHTTPString, PHTTPResource)
public:
/** Contruct a new simple string resource for the HTTP space. If no MIME
content type is specified then a default type is "text/html".
*/
PHTTPString(
const PURL & url // Name of the resource in URL space.
);
PHTTPString(
const PURL & url, // Name of the resource in URL space.
const PHTTPAuthority & auth // Authorisation for the resource.
);
PHTTPString(
const PURL & url, // Name of the resource in URL space.
const PString & str // String to return in this resource.
);
PHTTPString(
const PURL & url, // Name of the resource in URL space.
const PString & str, // String to return in this resource.
const PString & contentType // MIME content type for the file.
);
PHTTPString(
const PURL & url, // Name of the resource in URL space.
const PString & str, // String to return in this resource.
const PHTTPAuthority & auth // Authorisation for the resource.
);
PHTTPString(
const PURL & url, // Name of the resource in URL space.
const PString & str, // String to return in this resource.
const PString & contentType, // MIME content type for the file.
const PHTTPAuthority & auth // Authorisation for the resource.
);
// Overrides from class PHTTPResource
/** Get the headers for block of data (eg HTML) that the resource contains.
This will fill in all the fields of the <CODE>outMIME</CODE> parameter
required by the resource and return the status for the load.
@return
TRUE if all OK, FALSE if an error occurred.
*/
virtual BOOL LoadHeaders(
PHTTPRequest & request // Information on this request.
);
/** 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.
@return
String for loaded text.
*/
virtual PString LoadText(
PHTTPRequest & request // Information on this request.
);
// New functions for class.
/** Get the string for this resource.
@return
String for resource.
*/
const PString & GetString() { return string; }
/** Set the string to be returned by this resource.
*/
void SetString(
const PString & str // New string for the resource.
) { string = str; }
protected:
PString string;
};
//////////////////////////////////////////////////////////////////////////////
// PHTTPFile
/** This object describes a HyperText Transport Protocol resource which is a
single file. The file can be anywhere in the file system and is mapped to
the specified URL location in the HTTP name space defined by the
#PHTTPSpace# class.
*/
class PHTTPFile : public PHTTPResource
{
PCLASSINFO(PHTTPFile, PHTTPResource)
public:
/** Contruct a new simple file resource for the HTTP space. If no MIME
content type is specified then a default type is used depending on the
file type. For example, "text/html" is used of the file type is
".html" or ".htm". The default for an unknown type is
"application/octet-stream".
*/
PHTTPFile(
const PString & filename // file in file system and URL name.
);
PHTTPFile(
const PString & filename, // file in file system and URL name.
const PHTTPAuthority & auth // Authorisation for the resource.
);
PHTTPFile(
const PURL & url, // Name of the resource in URL space.
const PFilePath & file // Location of file in file system.
);
PHTTPFile(
const PURL & url, // Name of the resource in URL space.
const PFilePath & file, // Location of file in file system.
const PString & contentType // MIME content type for the file.
);
PHTTPFile(
const PURL & url, // Name of the resource in URL space.
const PFilePath & file, // Location of file in file system.
const PHTTPAuthority & auth // Authorisation for the resource.
);
PHTTPFile(
const PURL & url, // Name of the resource in URL space.
const PFilePath & file, // Location of file in file system.
const PString & contentType, // MIME content type for the file.
const PHTTPAuthority & auth // Authorisation for the resource.
);
// Overrides from class PHTTPResource
/** Create a new request block for this type of resource.
@return
Pointer to instance of PHTTPRequest descendant class.
*/
virtual PHTTPRequest * CreateRequest(
const PURL & url, // Universal Resource Locator for document.
const PMIMEInfo & inMIME, // Extra MIME information in command.
const PMultipartFormInfoArray & multipartFormInfo,
PHTTPServer & socket
);
/** Get the headers for block of data (eg HTML) that the resource contains.
This will fill in all the fields of the <CODE>outMIME</CODE> parameter
required by the resource and return the status for the load.
@return
TRUE if all OK, FALSE if an error occurred.
*/
virtual BOOL LoadHeaders(
PHTTPRequest & request // Information on this request.
);
/** Get a block of data that the resource contains.
@return
TRUE if more to load.
*/
virtual BOOL LoadData(
PHTTPRequest & request, // Information on this request.
PCharArray & data // Data used in reply.
);
/** 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.
@return
String for loaded text.
*/
virtual PString LoadText(
PHTTPRequest & request // Information on this request.
);
protected:
PHTTPFile(
const PURL & url, // Name of the resource in URL space.
int dummy
);
// Constructor used by PHTTPDirectory
PFilePath filePath;
};
class PHTTPFileRequest : public PHTTPRequest
{
PCLASSINFO(PHTTPFileRequest, PHTTPRequest)
public:
PHTTPFileRequest(
const PURL & url, // Universal Resource Locator for document.
const PMIMEInfo & inMIME, // Extra MIME information in command.
const PMultipartFormInfoArray & multipartFormInfo,
PHTTPServer & server
);
PFile file;
};
//////////////////////////////////////////////////////////////////////////////
// PHTTPTailFile
/** This object describes a HyperText Transport Protocol resource which is a
single file. The file can be anywhere in the file system and is mapped to
the specified URL location in the HTTP name space defined by the
#PHTTPSpace# class.
The difference between this and PHTTPFile is that it continually outputs
the contents of the file, as per the unix "tail -f" command.
*/
class PHTTPTailFile : public PHTTPFile
{
PCLASSINFO(PHTTPTailFile, PHTTPFile)
public:
/** Contruct a new simple file resource for the HTTP space. If no MIME
content type is specified then a default type is used depending on the
file type. For example, "text/html" is used of the file type is
".html" or ".htm". The default for an unknown type is
"application/octet-stream".
*/
PHTTPTailFile(
const PString & filename // file in file system and URL name.
);
PHTTPTailFile(
const PString & filename, // file in file system and URL name.
const PHTTPAuthority & auth // Authorisation for the resource.
);
PHTTPTailFile(
const PURL & url, // Name of the resource in URL space.
const PFilePath & file // Location of file in file system.
);
PHTTPTailFile(
const PURL & url, // Name of the resource in URL space.
const PFilePath & file, // Location of file in file system.
const PString & contentType // MIME content type for the file.
);
PHTTPTailFile(
const PURL & url, // Name of the resource in URL space.
const PFilePath & file, // Location of file in file system.
const PHTTPAuthority & auth // Authorisation for the resource.
);
PHTTPTailFile(
const PURL & url, // Name of the resource in URL space.
const PFilePath & file, // Location of file in file system.
const PString & contentType, // MIME content type for the file.
const PHTTPAuthority & auth // Authorisation for the resource.
);
// Overrides from class PHTTPResource
/** Get the headers for block of data (eg HTML) that the resource contains.
This will fill in all the fields of the <CODE>outMIME</CODE> parameter
required by the resource and return the status for the load.
@return
TRUE if all OK, FALSE if an error occurred.
*/
virtual BOOL LoadHeaders(
PHTTPRequest & request // Information on this request.
);
/** Get a block of data that the resource contains.
@return
TRUE if more to load.
*/
virtual BOOL LoadData(
PHTTPRequest & request, // Information on this request.
PCharArray & data // Data used in reply.
);
};
//////////////////////////////////////////////////////////////////////////////
// PHTTPDirectory
/** This object describes a HyperText Transport Protocol resource which is a
set of files in a directory. The directory can be anywhere in the file
system and is mapped to the specified URL location in the HTTP name space
defined by the #PHTTPSpace# class.
All subdirectories and files are available as URL names in the HTTP name
space. This effectively grafts a file system directory tree onto the URL
name space tree.
See the #PMIMEInfo# class for more information on the mappings between
file types and MIME types.
*/
class PHTTPDirectory : public PHTTPFile
{
PCLASSINFO(PHTTPDirectory, PHTTPFile)
public:
PHTTPDirectory(
const PURL & url, /// Name of the resource in URL space.
const PDirectory & dir /// Location of file in file system.
);
PHTTPDirectory(
const PURL & url, /// Name of the resource in URL space.
const PDirectory & dir, /// Location of file in file system.
const PHTTPAuthority & auth /// Authorisation for the resource.
);
// Construct a new directory resource for HTTP.
// Overrides from class PHTTPResource
/** Create a new request block for this type of resource.
@return
Pointer to instance of PHTTPRequest descendant class.
*/
virtual PHTTPRequest * CreateRequest(
const PURL & url, // Universal Resource Locator for document.
const PMIMEInfo & inMIME, // Extra MIME information in command.
const PMultipartFormInfoArray & multipartFormInfo,
PHTTPServer & socket
);
/** Get the headers for block of data (eg HTML) that the resource
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -