http.h
Go to the documentation of this file.
/*
* http.h
*
* HyperText Transport Protocol classes.
*
* Portable Windows Library
*
* Copyright (c) 1993-2002 Equivalence Pty. Ltd.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Portable Windows Library.
*
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
*
* Contributor(s): ______________________________________.
*
* $Revision: 29065 $
* $Author: rjongbloed $
* $Date: 2013-02-11 18:26:26 -0600 (Mon, 11 Feb 2013) $
*/
#ifndef PTLIB_HTTP_H
#define PTLIB_HTTP_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
#if P_HTTP
#include <ptclib/inetprot.h>
#include <ptclib/mime.h>
#include <ptclib/url.h>
#include <ptlib/ipsock.h>
#include <ptlib/pfactory.h>
#include <ptclib/html.h>
// PHTTPSpace
class PHTTPResource;
class PHTTPSpace : public PContainer
{
PCONTAINERINFO(PHTTPSpace, PContainer)
public:
PHTTPSpace();
// New functions for class.
enum AddOptions {
ErrorOnExist,
Overwrite
};
PBoolean AddResource(
PHTTPResource * resource,
AddOptions overwrite = ErrorOnExist
);
PBoolean DelResource(
const PURL & url
);
PHTTPResource * FindResource(
const PURL & url
);
void StartRead() const
{ mutex->StartRead(); }
void EndRead() const
{ mutex->EndRead(); }
void StartWrite() const
{ mutex->StartWrite(); }
void EndWrite() const
{ mutex->EndWrite(); }
protected:
PReadWriteMutex * mutex;
class Node;
PSORTED_LIST(ChildList, Node);
class Node : public PString
{
PCLASSINFO(Node, PString)
public:
Node(const PString & name, Node * parentNode);
~Node();
Node * parent;
ChildList children;
PHTTPResource * resource;
} * root;
private:
PBoolean SetSize(PINDEX) { return false; }
};
#ifdef TRACE
#undef TRACE
#endif
// PHTTP
class PHTTP : public PInternetProtocol
{
PCLASSINFO(PHTTP, PInternetProtocol)
public:
// New functions for class.
enum Commands {
// HTTP/1.0 commands
GET, HEAD, POST,
// HTTP/1.1 commands
PUT, DELETE, TRACE, OPTIONS,
// HTTPS command
CONNECT,
NumCommands
};
enum StatusCode {
Continue = 100,
SwitchingProtocols,
RequestOK = 200,
Created,
Accepted,
NonAuthoritativeInformation,
NoContent,
ResetContent,
PartialContent,
MultipleChoices = 300,
MovedPermanently,
MovedTemporarily,
SeeOther,
NotModified,
UseProxy,
BadRequest = 400,
UnAuthorised,
PaymentRequired,
Forbidden,
NotFound,
MethodNotAllowed,
NoneAcceptable,
ProxyAuthenticationRequired,
RequestTimeout,
Conflict,
Gone,
LengthRequired,
UnlessTrue,
InternalServerError = 500,
NotImplemented,
BadGateway,
ServiceUnavailable,
GatewayTimeout
};
// Common MIME header tags
static const PCaselessString & AllowTag();
static const PCaselessString & AuthorizationTag();
static const PCaselessString & ContentEncodingTag();
static const PCaselessString & ContentLengthTag();
static const PCaselessString & ContentTypeTag() { return PMIMEInfo::ContentTypeTag(); }
static const PCaselessString & DateTag();
static const PCaselessString & ExpiresTag();
static const PCaselessString & FromTag();
static const PCaselessString & IfModifiedSinceTag();
static const PCaselessString & LastModifiedTag();
static const PCaselessString & LocationTag();
static const PCaselessString & PragmaTag();
static const PCaselessString & PragmaNoCacheTag();
static const PCaselessString & RefererTag();
static const PCaselessString & ServerTag();
static const PCaselessString & UserAgentTag();
static const PCaselessString & WWWAuthenticateTag();
static const PCaselessString & MIMEVersionTag();
static const PCaselessString & ConnectionTag();
static const PCaselessString & KeepAliveTag();
static const PCaselessString & TransferEncodingTag();
static const PCaselessString & ChunkedTag();
static const PCaselessString & ProxyConnectionTag();
static const PCaselessString & ProxyAuthorizationTag();
static const PCaselessString & ProxyAuthenticateTag();
static const PCaselessString & ForwardedTag();
static const PCaselessString & SetCookieTag();
static const PCaselessString & CookieTag();
protected:
PHTTP();
virtual PINDEX ParseResponse(
const PString & line
);
};
class PHTTPClientAuthentication : public PObject
{
PCLASSINFO(PHTTPClientAuthentication, PObject);
public:
class AuthObject {
public:
virtual ~AuthObject() { }
virtual PMIMEInfo & GetMIME() = 0;
virtual PString GetURI() = 0;
virtual PString GetEntityBody() = 0;
virtual PString GetMethod() = 0;
};
PHTTPClientAuthentication();
virtual Comparison Compare(
const PObject & other
) const;
virtual PBoolean Parse(
const PString & auth,
PBoolean proxy
) = 0;
virtual PBoolean Authorise(
AuthObject & pdu
) const = 0;
virtual PBoolean IsProxy() const { return isProxy; }
virtual PString GetUsername() const { return username; }
virtual PString GetPassword() const { return password; }
virtual PString GetAuthRealm() const { return PString::Empty(); }
virtual void SetUsername(const PString & user) { username = user; }
virtual void SetPassword(const PString & pass) { password = pass; }
virtual void SetAuthRealm(const PString &) { }
PString GetAuthParam(const PString & auth, const char * name) const;
PString AsHex(PMessageDigest5::Code & digest) const;
PString AsHex(const PBYTEArray & data) const;
static PHTTPClientAuthentication * ParseAuthenticationRequired(bool isProxy, const PMIMEInfo & line, PString & errorMsg);
protected:
PBoolean isProxy;
PString username;
PString password;
};
typedef PFactory<PHTTPClientAuthentication> PHTTPClientAuthenticationFactory;
class PHTTPClientAuthenticator : public PHTTPClientAuthentication::AuthObject
{
public:
PHTTPClientAuthenticator(
const PString & cmdName,
const PString & uri,
PMIMEInfo & mime,
const PString & body
);
virtual PMIMEInfo & GetMIME();
virtual PString GetURI();
virtual PString GetEntityBody();
virtual PString GetMethod();
protected:
PString m_method;
PString m_uri;
PMIMEInfo & m_mime;
PString m_body;
};
class PHTTPClientBasicAuthentication : public PHTTPClientAuthentication
{
PCLASSINFO(PHTTPClientBasicAuthentication, PHTTPClientAuthentication);
public:
PHTTPClientBasicAuthentication();
virtual Comparison Compare(
const PObject & other
) const;
virtual PBoolean Parse(
const PString & auth,
PBoolean proxy
);
virtual PBoolean Authorise(
AuthObject & pdu
) const;
};
class PHTTPClientDigestAuthentication : public PHTTPClientAuthentication
{
PCLASSINFO(PHTTPClientDigestAuthentication, PHTTPClientAuthentication);
public:
PHTTPClientDigestAuthentication();
PHTTPClientDigestAuthentication & operator =(
const PHTTPClientDigestAuthentication & auth
);
virtual Comparison Compare(
const PObject & other
) const;
virtual PBoolean Parse(
const PString & auth,
PBoolean proxy
);
virtual PBoolean Authorise(
AuthObject & pdu
) const;
virtual PString GetAuthRealm() const { return authRealm; }
virtual void SetAuthRealm(const PString & r) { authRealm = r; }
enum Algorithm {
Algorithm_MD5,
NumAlgorithms
};
const PString & GetNonce() const { return nonce; }
Algorithm GetAlgorithm() const { return algorithm; }
const PString & GetOpaque() const { return opaque; }
bool GetStale() const { return stale; }
protected:
PString authRealm;
PString nonce;
Algorithm algorithm;
PString opaque;
bool qopAuth;
bool qopAuthInt;
bool stale;
PString cnonce;
mutable PAtomicInteger nonceCount;
};
// PHTTPClient
class PHTTPClient : public PHTTP
{
PCLASSINFO(PHTTPClient, PHTTP)
public:
PHTTPClient(
const PString & userAgentName = PString::Empty()
);
// New functions for class.
int ExecuteCommand(
Commands cmd,
const PURL & url,
PMIMEInfo & outMIME,
const PString & dataBody,
PMIMEInfo & replyMime
);
int ExecuteCommand(
const PString & cmdName,
const PURL & url,
PMIMEInfo & outMIME,
const PString & dataBody,
PMIMEInfo & replyMime
);
bool WriteCommand(
Commands cmd,
const PString & url,
PMIMEInfo & outMIME,
const PString & dataBody
);
bool WriteCommand(
const PString & cmdName,
const PString & url,
PMIMEInfo & outMIME,
const PString & dataBody
);
bool ReadResponse(
PMIMEInfo & replyMIME
);
bool ReadContentBody(
PMIMEInfo & replyMIME
);
bool ReadContentBody(
PMIMEInfo & replyMIME,
PString & body
);
bool ReadContentBody(
PMIMEInfo & replyMIME,
PBYTEArray & body
);
bool GetDocument(
const PURL & url,
PMIMEInfo & outMIME,
PMIMEInfo & replyMIME
);
bool GetDocument(
const PURL & url,
PMIMEInfo & replyMIME
);
bool GetTextDocument(
const PURL & url,
PString & document,
const PString & contentType = PString::Empty()
);
bool GetHeader(
const PURL & url,
PMIMEInfo & outMIME,
PMIMEInfo & replyMIME
);
bool PostData(
const PURL & url,
const PStringToString & data
);
bool PostData(
const PURL & url,
PMIMEInfo & outMIME,
const PString & data
);
bool PostData(
const PURL & url,
PMIMEInfo & outMIME,
const PString & data,
PMIMEInfo & replyMIME
);
bool PostData(
const PURL & url,
PMIMEInfo & outMIME,
const PString & data,
PMIMEInfo & replyMIME,
PString & replyBody
);
bool PutTextDocument(
const PURL & url,
const PString & document,
const PString & contentType = PMIMEInfo::TextPlain()
);
bool PutDocument(
const PURL & url,
PMIMEInfo & outMIME,
PMIMEInfo & replyMIME
);
bool DeleteDocument(
const PURL & url
);
void SetAuthenticationInfo(
const PString & userName,
const PString & password
);
void SetPersistent(
bool persist = true
) { m_persist = persist; }
bool GetPersistent() const { return m_persist; }
protected:
bool AssureConnect(const PURL & url, PMIMEInfo & outMIME);
bool InternalReadContentBody(
PMIMEInfo & replyMIME,
PAbstractArray * body
);
PString m_userAgentName;
bool m_persist;
PString m_userName;
PString m_password;
PHTTPClientAuthentication * m_authentication;
};
// PHTTPConnectionInfo
class PHTTPServer;
class PHTTPConnectionInfo : public PObject
{
PCLASSINFO(PHTTPConnectionInfo, PObject)
public:
PHTTPConnectionInfo();
PHTTP::Commands GetCommandCode() const { return commandCode; }
const PString & GetCommandName() const { return commandName; }
const PURL & GetURL() const { return url; }
const PMIMEInfo & GetMIME() const { return mimeInfo; }
void SetMIME(const PString & tag, const PString & value);
PBoolean IsCompatible(int major, int minor) const;
bool IsPersistent() const { return isPersistent; }
bool WasPersistent() const { return wasPersistent; }
bool IsProxyConnection() const { return isProxyConnection; }
int GetMajorVersion() const { return majorVersion; }
int GetMinorVersion() const { return minorVersion; }
long GetEntityBodyLength() const { return entityBodyLength; }
PTimeInterval GetPersistenceTimeout() const { return persistenceTimeout; }
void SetPersistenceTimeout(const PTimeInterval & t) { persistenceTimeout = t; }
unsigned GetPersistenceMaximumTransations() const { return persistenceMaximum; }
void SetPersistenceMaximumTransations(unsigned m) { persistenceMaximum = m; }
const PMultiPartList & GetMultipartFormInfo() const
{ return m_multipartFormInfo; }
void ResetMultipartFormInfo()
{ m_multipartFormInfo.RemoveAll(); }
PString GetEntityBody() const { return entityBody; }
protected:
PBoolean Initialise(PHTTPServer & server, PString & args);
bool DecodeMultipartFormInfo() { return mimeInfo.DecodeMultiPartList(m_multipartFormInfo, entityBody); }
PHTTP::Commands commandCode;
PString commandName;
PURL url;
PMIMEInfo mimeInfo;
bool isPersistent;
bool wasPersistent;
bool isProxyConnection;
int majorVersion;
int minorVersion;
PString entityBody; // original entity body (POST only)
long entityBodyLength;
PTimeInterval persistenceTimeout;
unsigned persistenceMaximum;
PMultiPartList m_multipartFormInfo;
friend class PHTTPServer;
};
// PHTTPServer
class PHTTPServer : public PHTTP
{
PCLASSINFO(PHTTPServer, PHTTP)
public:
PHTTPServer();
PHTTPServer(
const PHTTPSpace & urlSpace
);
// New functions for class.
virtual PString GetServerName() const;
PHTTPSpace & GetURLSpace() { return urlSpace; }
void SetURLSpace(
const PHTTPSpace & space
);
virtual PBoolean ProcessCommand();
virtual PBoolean OnGET(
const PURL & url,
const PMIMEInfo & info,
const PHTTPConnectionInfo & conInfo
);
virtual PBoolean OnHEAD(
const PURL & url,
const PMIMEInfo & info,
const PHTTPConnectionInfo & conInfo
);
virtual PBoolean OnPOST(
const PURL & url,
const PMIMEInfo & info,
const PStringToString & data,
const PHTTPConnectionInfo & conInfo
);
virtual PBoolean OnProxy(
const PHTTPConnectionInfo & conInfo
);
virtual PString ReadEntityBody();
virtual PBoolean OnUnknown(
const PCaselessString & command,
const PHTTPConnectionInfo & connectInfo
);
PBoolean StartResponse(
StatusCode code,
PMIMEInfo & headers,
long bodySize
);
virtual PBoolean OnError(
StatusCode code,
const PCaselessString & extra,
const PHTTPConnectionInfo & connectInfo
);
void SetDefaultMIMEInfo(
PMIMEInfo & info,
const PHTTPConnectionInfo & connectInfo
);
PHTTPConnectionInfo & GetConnectionInfo() { return connectInfo; }
protected:
void Construct();
PHTTPSpace urlSpace;
PHTTPConnectionInfo connectInfo;
unsigned transactionCount;
PTimeInterval nextTimeout;
};
// PHTTPRequest
class PHTTPRequest : public PObject
{
PCLASSINFO(PHTTPRequest, PObject)
public:
PHTTPRequest(
const PURL & url,
const PMIMEInfo & inMIME,
const PMultiPartList & multipartFormInfo,
PHTTPResource * resource,
PHTTPServer & server
);
PHTTPServer & server;
const PURL & url;
const PMIMEInfo & inMIME;
const PMultiPartList & multipartFormInfo;
PHTTP::StatusCode code;
PMIMEInfo outMIME;
PString entityBody;
PINDEX contentSize;
PIPSocket::Address origin;
PIPSocket::Address localAddr;
WORD localPort;
PHTTPResource * m_resource;
};
// PHTTPAuthority
class PHTTPAuthority : public PObject
{
PCLASSINFO(PHTTPAuthority, PObject)
public:
// New functions for class.
virtual PString GetRealm(
const PHTTPRequest & request
) const = 0;
virtual PBoolean Validate(
const PHTTPRequest & request,
const PString & authInfo
) const = 0;
virtual PBoolean IsActive() const;
protected:
static void DecodeBasicAuthority(
const PString & authInfo,
PString & username,
PString & password
);
};
// PHTTPSimpleAuth
class PHTTPSimpleAuth : public PHTTPAuthority
{
PCLASSINFO(PHTTPSimpleAuth, PHTTPAuthority)
public:
PHTTPSimpleAuth(
const PString & realm,
const PString & username,
const PString & password
);
// Construct the simple authorisation structure.
// Overrides from class PObject.
virtual PObject * Clone() const;
// Overrides from class PHTTPAuthority.
virtual PString GetRealm(
const PHTTPRequest & request
) const;
virtual PBoolean Validate(
const PHTTPRequest & request,
const PString & authInfo
) const;
virtual PBoolean IsActive() const;
const PString & GetUserName() const { return username; }
const PString & GetPassword() const { return password; }
protected:
PString realm;
PString username;
PString password;
};
// PHTTPMultiSimpAuth
class PHTTPMultiSimpAuth : public PHTTPAuthority
{
PCLASSINFO(PHTTPMultiSimpAuth, PHTTPAuthority)
public:
PHTTPMultiSimpAuth(
const PString & realm
);
PHTTPMultiSimpAuth(
const PString & realm,
const PStringToString & userList
);
// Construct the simple authorisation structure.
// Overrides from class PObject.
virtual PObject * Clone() const;
// Overrides from class PHTTPAuthority.
virtual PString GetRealm(
const PHTTPRequest & request
) const;
virtual PBoolean Validate(
const PHTTPRequest & request,
const PString & authInfo
) const;
virtual PBoolean IsActive() const;
void AddUser(
const PString & username,
const PString & password
);
protected:
PString realm;
PStringToString users;
};
// PHTTPResource
class PHTTPResource : public PObject
{
PCLASSINFO(PHTTPResource, PObject)
protected:
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
);
// Create a new HTTP Resource.
public:
virtual ~PHTTPResource();
// Destroy the HTTP Resource.
// New functions for class.
const PURL & GetURL() const { return baseURL; }
const PString & GetContentType() const { return contentType; }
PHTTPAuthority * GetAuthority() const { return authority; }
void SetAuthority(
const PHTTPAuthority & auth
);
void ClearAuthority();
DWORD GetHitCount() const { return hitCount; }
void ClearHitCount() { hitCount = 0; }
// Clear the hit count for the resource.
virtual PBoolean OnGET(
PHTTPServer & server,
const PURL & url,
const PMIMEInfo & info,
const PHTTPConnectionInfo & conInfo
);
virtual PBoolean OnGETData(
PHTTPServer & server,
const PURL & url,
const PHTTPConnectionInfo & connectInfo,
PHTTPRequest & request
);
virtual PBoolean OnHEAD(
PHTTPServer & server,
const PURL & url,
const PMIMEInfo & info,
const PHTTPConnectionInfo & conInfo
);
virtual PBoolean OnPOST(
PHTTPServer & server,
const PURL & url,
const PMIMEInfo & info,
const PStringToString & data,
const PHTTPConnectionInfo & conInfo
);
virtual PBoolean OnPOSTData(
PHTTPRequest & request,
const PStringToString & data
);
virtual PBoolean IsModifiedSince(
const PTime & when
);
virtual PBoolean GetExpirationDate(
PTime & when
);
virtual PHTTPRequest * CreateRequest(
const PURL & url,
const PMIMEInfo & inMIME,
const PMultiPartList & multipartFormInfo,
PHTTPServer & socket
);
virtual PBoolean LoadHeaders(
PHTTPRequest & request
) = 0;
virtual void SendData(
PHTTPRequest & request
);
virtual PBoolean LoadData(
PHTTPRequest & request,
PCharArray & data
);
virtual PString LoadText(
PHTTPRequest & request
);
virtual void OnLoadedText(
PHTTPRequest & request,
PString & text
);
virtual PBoolean Post(
PHTTPRequest & request,
const PStringToString & data,
PHTML & replyMessage
);
protected:
virtual PBoolean CheckAuthority(
PHTTPServer & server,
const PHTTPRequest & request,
const PHTTPConnectionInfo & conInfo
);
static PBoolean CheckAuthority(
PHTTPAuthority & authority,
PHTTPServer & server,
const PHTTPRequest & request,
const PHTTPConnectionInfo & connectInfo
);
virtual PBoolean OnGETOrHEAD(
PHTTPServer & server,
const PURL & url,
const PMIMEInfo & info,
const PHTTPConnectionInfo & conInfo,
PBoolean isGet
);
PURL baseURL;
PString contentType;
PHTTPAuthority * authority;
volatile DWORD hitCount;
};
// PHTTPString
class PHTTPString : public PHTTPResource
{
PCLASSINFO(PHTTPString, PHTTPResource)
public:
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
virtual PBoolean LoadHeaders(
PHTTPRequest & request // Information on this request.
);
virtual PString LoadText(
PHTTPRequest & request // Information on this request.
);
// New functions for class.
const PString & GetString() { return string; }
void SetString(
const PString & str // New string for the resource.
) { string = str; }
protected:
PString string;
};
// PHTTPFile
class PHTTPFile : public PHTTPResource
{
PCLASSINFO(PHTTPFile, PHTTPResource)
public:
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
virtual PHTTPRequest * CreateRequest(
const PURL & url, // Universal Resource Locator for document.
const PMIMEInfo & inMIME, // Extra MIME information in command.
const PMultiPartList & multipartFormInfo,
PHTTPServer & socket
);
virtual PBoolean LoadHeaders(
PHTTPRequest & request // Information on this request.
);
virtual PBoolean LoadData(
PHTTPRequest & request, // Information on this request.
PCharArray & data // Data used in reply.
);
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 PMultiPartList & multipartFormInfo,
PHTTPResource * resource,
PHTTPServer & server
);
PFile file;
};
// PHTTPTailFile
class PHTTPTailFile : public PHTTPFile
{
PCLASSINFO(PHTTPTailFile, PHTTPFile)
public:
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
virtual PBoolean LoadHeaders(
PHTTPRequest & request // Information on this request.
);
virtual PBoolean LoadData(
PHTTPRequest & request, // Information on this request.
PCharArray & data // Data used in reply.
);
};
// PHTTPDirectory
class PHTTPDirectory : public PHTTPFile
{
PCLASSINFO(PHTTPDirectory, PHTTPFile)
public:
PHTTPDirectory(
const PURL & url,
const PDirectory & dir
);
PHTTPDirectory(
const PURL & url,
const PDirectory & dir,
const PHTTPAuthority & auth
);
// Construct a new directory resource for HTTP.
// Overrides from class PHTTPResource
virtual PHTTPRequest * CreateRequest(
const PURL & url, // Universal Resource Locator for document.
const PMIMEInfo & inMIME, // Extra MIME information in command.
const PMultiPartList & multipartFormInfo,
PHTTPServer & socket
);
virtual PBoolean LoadHeaders(
PHTTPRequest & request
);
virtual PString LoadText(
PHTTPRequest & request
);
void EnableAuthorisation(const PString & realm);
void AllowDirectories(PBoolean enable = true);
protected:
PBoolean CheckAuthority(
PHTTPServer & server, // Server to send response to.
const PHTTPRequest & request, // Information on this request.
const PHTTPConnectionInfo & conInfo // Information on the connection
);
PBoolean FindAuthorisations(const PDirectory & dir, PString & realm, PStringToString & authorisations);
PDirectory basePath;
PString authorisationRealm;
PBoolean allowDirectoryListing;
};
class PHTTPDirRequest : public PHTTPFileRequest
{
PCLASSINFO(PHTTPDirRequest, PHTTPFileRequest)
public:
PHTTPDirRequest(
const PURL & url, // Universal Resource Locator for document.
const PMIMEInfo & inMIME, // Extra MIME information in command.
const PMultiPartList & multipartFormInfo,
PHTTPResource * resource,
PHTTPServer & server
);
PString fakeIndex;
PFilePath realPath;
};
PFACTORY_LOAD(PURL_HttpLoader);
#endif // P_HTTP
#endif // PTLIB_HTTP_H
// End Of File ///////////////////////////////////////////////////////////////
PHTTP::TransferEncodingTag
static const PCaselessString & TransferEncodingTag()
PHTTPConnectionInfo::SetPersistenceMaximumTransations
void SetPersistenceMaximumTransations(unsigned m)
Set the maximum number of transations (GET/POST etc) for persistent connection.
Definition: http.h:705
PHTTPConnectionInfo::commandName
PString commandName
Definition: http.h:720
PHTTPConnectionInfo::SetMIME
void SetMIME(const PString &tag, const PString &value)
PHTTPString::SetString
void SetString(const PString &str)
Set the string to be returned by this resource.
Definition: http.h:1596
PReadWriteMutex::EndRead
void EndRead()
This function attempts to release the mutex for reading.
PHTTPClientDigestAuthentication
Definition: http.h:364
PHTTPResource::Post
virtual PBoolean Post(PHTTPRequest &request, const PStringToString &data, PHTML &replyMessage)
Get a block of data (eg HTML) that the resource contains.
PHTTPClientAuthentication::GetPassword
virtual PString GetPassword() const
Definition: http.h:298
PHTTPConnectionInfo::PHTTPConnectionInfo
PHTTPConnectionInfo()
inetprot.h
PHTTPClientDigestAuthentication::Parse
virtual PBoolean Parse(const PString &auth, PBoolean proxy)
PHTTPClientAuthentication::SetPassword
virtual void SetPassword(const PString &pass)
Definition: http.h:302
PHTTPClientAuthentication::AuthObject::GetMIME
virtual PMIMEInfo & GetMIME()=0
PHTTPSimpleAuth::GetPassword
const PString & GetPassword() const
Get the password allocated to this simple authorisation.
Definition: http.h:1124
PHTTPSpace::root
PHTTPSpace::Node * root
PMIMEInfo::ContentTypeTag
static const PCaselessString & ContentTypeTag()
PMIMEInfo::DecodeMultiPartList
bool DecodeMultiPartList(PMultiPartList &parts, const PString &body, const PCaselessString &key) const
Decode parts from a multipart body using the field value.
PHTTPConnectionInfo::Initialise
PBoolean Initialise(PHTTPServer &server, PString &args)
PHTTPClient::GetPersistent
bool GetPersistent() const
Get persistent connection mode.
Definition: http.h:639
PHTTPServer::OnHEAD
virtual PBoolean OnHEAD(const PURL &url, const PMIMEInfo &info, const PHTTPConnectionInfo &conInfo)
Handle a HEAD command from a client.
PMIMEInfo
This class contains the Multipurpose Internet Mail Extensions parameters and variables.
Definition: mime.h:52
PHTTP::ExpiresTag
static const PCaselessString & ExpiresTag()
PMultiPartList
Definition: mime.h:295
PHTTPConnectionInfo::entityBody
PString entityBody
Definition: http.h:728
PHTTPClientDigestAuthentication::GetNonce
const PString & GetNonce() const
Definition: http.h:394
PHTTPResource::hitCount
volatile DWORD hitCount
COunt of number of times resource was accessed.
Definition: http.h:1514
PHTTPSimpleAuth::IsActive
virtual PBoolean IsActive() const
Determine if the authorisation is to be applied.
PHTTP::MovedPermanently
301 - resource moved permanently: location field has new URL
Definition: http.h:189
PFile
This class represents a disk file.
Definition: file.h:60
PHTTPSimpleAuth::username
PString username
Definition: http.h:1129
PHTTPClientAuthentication::IsProxy
virtual PBoolean IsProxy() const
Definition: http.h:295
PHTTPClient::DeleteDocument
bool DeleteDocument(const PURL &url)
Delete the document specified by the URL.
PHTTPSpace::Node
Definition: http.h:136
PHTTP::CookieTag
static const PCaselessString & CookieTag()
PHTTPClientDigestAuthentication::operator=
PHTTPClientDigestAuthentication & operator=(const PHTTPClientDigestAuthentication &auth)
PTimeInterval
This class defines an arbitrary time interval to millisecond accuracy.
Definition: timeint.h:55
PHTTPConnectionInfo::WasPersistent
bool WasPersistent() const
Definition: http.h:682
PHTTP::AuthorizationTag
static const PCaselessString & AuthorizationTag()
PHTTPSpace::EndRead
void EndRead() const
This function attempts to release the mutex for reading.
Definition: http.h:117
PCharArray
Array of characters.
Definition: array.h:551
PHTTP::UnlessTrue
412 - no Range header for true Unless
Definition: http.h:206
PHTTPMultiSimpAuth::GetRealm
virtual PString GetRealm(const PHTTPRequest &request) const
Get the realm or name space for the user authorisation name and password as required by the basic aut...
PHTTPServer::PHTTPServer
PHTTPServer()
Create a TCP/IP HTTP protocol socket channel.
PHTTPSimpleAuth::GetRealm
virtual PString GetRealm(const PHTTPRequest &request) const
Get the realm or name space for the user authorisation name and password as required by the basic aut...
PCLASSINFO
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:1049
PHTTPDirectory::EnableAuthorisation
void EnableAuthorisation(const PString &realm)
Enable or disable access control using .access files.
PHTTPClientAuthentication::AuthObject::GetEntityBody
virtual PString GetEntityBody()=0
PHTTPClientDigestAuthentication::Authorise
virtual PBoolean Authorise(AuthObject &pdu) const
PHTTPClientAuthenticator::m_uri
PString m_uri
Definition: http.h:335
PHTTP::InternalServerError
500 - server has encountered an unexpected error
Definition: http.h:207
PHTTPClient::ReadContentBody
bool ReadContentBody(PMIMEInfo &replyMIME)
Read the body of the HTTP command, throwing it away.
PHTTP::LocationTag
static const PCaselessString & LocationTag()
PHTTPDirectory::CheckAuthority
PBoolean CheckAuthority(PHTTPServer &server, const PHTTPRequest &request, const PHTTPConnectionInfo &conInfo)
See if the resource is authorised given the mime info.
PHTTPResource::LoadData
virtual PBoolean LoadData(PHTTPRequest &request, PCharArray &data)
Get a block of data that the resource contains.
pfactory.h
PHTTPServer::StartResponse
PBoolean StartResponse(StatusCode code, PMIMEInfo &headers, long bodySize)
Write a command reply back to the client, and construct some of the outgoing MIME fields...
PHTTPSpace::PSORTED_LIST
PSORTED_LIST(ChildList, Node)
PHTTPResource::GetAuthority
PHTTPAuthority * GetAuthority() const
Get the current authority for the resource.
Definition: http.h:1272
PHTTP::NumCommands
Definition: http.h:175
PHTTPSimpleAuth
This class describes the simplest authorisation mechanism for a Universal Resource Locator...
Definition: http.h:1055
PHTTPSpace::Node::resource
PHTTPResource * resource
Definition: http.h:145
PHTTPResource::ClearHitCount
void ClearHitCount()
Definition: http.h:1292
PHTTP::RefererTag
static const PCaselessString & RefererTag()
html.h
PHTTPSimpleAuth::password
PString password
Definition: http.h:1130
PHTTPConnectionInfo::IsProxyConnection
bool IsProxyConnection() const
Definition: http.h:683
PHTTPAuthority
This abstract class describes the authorisation mechanism for a Universal Resource Locator...
Definition: http.h:1002
PTime
This class defines an absolute time and date.
Definition: ptime.h:53
PHTTPMultiSimpAuth::Clone
virtual PObject * Clone() const
Create a copy of the class on the heap.
PHTTPServer::OnPOST
virtual PBoolean OnPOST(const PURL &url, const PMIMEInfo &info, const PStringToString &data, const PHTTPConnectionInfo &conInfo)
Handle a POST command from a client.
PHTTP::PragmaNoCacheTag
static const PCaselessString & PragmaNoCacheTag()
PHTTP::WWWAuthenticateTag
static const PCaselessString & WWWAuthenticateTag()
PHTTPClientAuthentication::SetUsername
virtual void SetUsername(const PString &user)
Definition: http.h:301
PHTTPDirRequest::realPath
PFilePath realPath
Definition: http.h:1914
PHTTP::ServiceUnavailable
503 - server temporarily unable to service request
Definition: http.h:210
PHTTPClient::ExecuteCommand
int ExecuteCommand(Commands cmd, const PURL &url, PMIMEInfo &outMIME, const PString &dataBody, PMIMEInfo &replyMime)
Send a command and wait for the response header (including MIME fields).
PReadWriteMutex::StartWrite
void StartWrite()
This function attempts to acquire the mutex for writing.
PHTTPResource::OnGETOrHEAD
virtual PBoolean OnGETOrHEAD(PHTTPServer &server, const PURL &url, const PMIMEInfo &info, const PHTTPConnectionInfo &conInfo, PBoolean isGet)
common code for GET and HEAD commands
PHTTPString::LoadText
virtual PString LoadText(PHTTPRequest &request)
Get a block of text data (eg HTML) that the resource contains.
PHTTPResource::GetContentType
const PString & GetContentType() const
Get the current content type for the resource.
Definition: http.h:1264
PHTTPClientDigestAuthentication::Algorithm
Algorithm
Definition: http.h:390
PHTTPResource::SetAuthority
void SetAuthority(const PHTTPAuthority &auth)
Set the current authority for the resource.
PReadWriteMutex::StartRead
void StartRead()
This function attempts to acquire the mutex for reading.
PHTTPRequest::multipartFormInfo
const PMultiPartList & multipartFormInfo
multipart form information, if any
Definition: http.h:984
PHTTPServer::SetDefaultMIMEInfo
void SetDefaultMIMEInfo(PMIMEInfo &info, const PHTTPConnectionInfo &connectInfo)
Set the default mime info.
PHTTP::ContentLengthTag
static const PCaselessString & ContentLengthTag()
PHTTP::PUT
Definition: http.h:172
PHTTP::ProxyConnectionTag
static const PCaselessString & ProxyConnectionTag()
PHTTPClientBasicAuthentication::Compare
virtual Comparison Compare(const PObject &other) const
Compare the two objects and return their relative rank.
PHTTP::NonAuthoritativeInformation
203 - not definitive entity header
Definition: http.h:184
PHTTP::ResetContent
205 - contents have been reset
Definition: http.h:186
PHTTPConnectionInfo::commandCode
PHTTP::Commands commandCode
Definition: http.h:719
PHTTPClientAuthenticator::GetURI
virtual PString GetURI()
PHTTPClientAuthenticator::GetEntityBody
virtual PString GetEntityBody()
PHTTPClient::GetHeader
bool GetHeader(const PURL &url, PMIMEInfo &outMIME, PMIMEInfo &replyMIME)
Get the header for the document specified by the URL.
PHTTPClientAuthentication
Definition: http.h:267
PHTTPResource::CheckAuthority
virtual PBoolean CheckAuthority(PHTTPServer &server, const PHTTPRequest &request, const PHTTPConnectionInfo &conInfo)
See if the resource is authorised given the mime info.
PHTTPSpace::ErrorOnExist
Generate error if resource already exists.
Definition: http.h:68
PHTTPClient::GetDocument
bool GetDocument(const PURL &url, PMIMEInfo &outMIME, PMIMEInfo &replyMIME)
Start getting the document specified by the URL.
PHTTPServer::GetServerName
virtual PString GetServerName() const
Get the name of the server.
PHTTP::SeeOther
303 - see other URL
Definition: http.h:191
PHTTPFileRequest::PHTTPFileRequest
PHTTPFileRequest(const PURL &url, const PMIMEInfo &inMIME, const PMultiPartList &multipartFormInfo, PHTTPResource *resource, PHTTPServer &server)
PStringToString
This is a dictionary collection class of PString objects, keyed by another string.
Definition: pstring.h:2784
PFilePath
This class describes a full description for a file on the particular platform.
Definition: filepath.h:65
PHTTPDirectory::allowDirectoryListing
PBoolean allowDirectoryListing
Definition: http.h:1897
PHTTP::SetCookieTag
static const PCaselessString & SetCookieTag()
PHTTPClientAuthentication::isProxy
PBoolean isProxy
Definition: http.h:313
PHTTPClient::m_password
PString m_password
Definition: http.h:651
PHTTPClientAuthentication::Compare
virtual Comparison Compare(const PObject &other) const
Compare the two objects and return their relative rank.
PObject::Comparison
Comparison
Result of the comparison operation performed by the Compare() function.
Definition: object.h:1184
PHTTPClient::InternalReadContentBody
bool InternalReadContentBody(PMIMEInfo &replyMIME, PAbstractArray *body)
PHTTPMultiSimpAuth::AddUser
void AddUser(const PString &username, const PString &password)
Get the user name allocated to this simple authorisation.
PHTTPResource::authority
PHTTPAuthority * authority
Authorisation method for the resource.
Definition: http.h:1513
PHTTPSpace::FindResource
PHTTPResource * FindResource(const PURL &url)
Locate the resource specified by the URL in the URL name space.
PHTTP::ContentEncodingTag
static const PCaselessString & ContentEncodingTag()
PHTTPMultiSimpAuth::Validate
virtual PBoolean Validate(const PHTTPRequest &request, const PString &authInfo) const
Validate the user and password provided by the remote HTTP client for the realm specified by the clas...
PCaselessString
This class is a variation of a string that ignores case.
Definition: pstring.h:1708
PHTTPString::string
PString string
Definition: http.h:1602
PHTTPFileRequest::file
PFile file
Definition: http.h:1725
PHTTPClientAuthenticator::m_mime
PMIMEInfo & m_mime
Definition: http.h:336
PHTTPClient::m_userAgentName
PString m_userAgentName
Definition: http.h:648
PHTTPServer::GetURLSpace
PHTTPSpace & GetURLSpace()
Get the name space being used by the HTTP server socket.
Definition: http.h:793
PHTTPDirRequest
Definition: http.h:1901
PHTTPSpace::EndWrite
void EndWrite() const
This function attempts to release the mutex for writing.
Definition: http.h:127
PHTTPClientDigestAuthentication::SetAuthRealm
virtual void SetAuthRealm(const PString &r)
Definition: http.h:388
PHTTP::ServerTag
static const PCaselessString & ServerTag()
PHTTPSpace::AddResource
PBoolean AddResource(PHTTPResource *resource, AddOptions overwrite=ErrorOnExist)
Add a new resource to the URL space.
PHTTPConnectionInfo::wasPersistent
bool wasPersistent
Definition: http.h:724
PHTTPSimpleAuth::Clone
virtual PObject * Clone() const
Create a copy of the class on the heap.
PHTTP::POST
Definition: http.h:170
PHTTPClientDigestAuthentication::stale
bool stale
Definition: http.h:407
PHTTPSpace::Overwrite
Overwrite the existing resource at URL location.
Definition: http.h:69
PHTTPSpace::StartRead
void StartRead() const
This function attempts to acquire the mutex for reading.
Definition: http.h:112
PHTTP::ProxyAuthorizationTag
static const PCaselessString & ProxyAuthorizationTag()
PHTTPDirectory::LoadHeaders
virtual PBoolean LoadHeaders(PHTTPRequest &request)
Get the headers for block of data (eg HTML) that the resource contains.
PHTTP::NotImplemented
501 - server does not implement request
Definition: http.h:208
PHTTPFileRequest
Definition: http.h:1713
PHTTPAuthority::IsActive
virtual PBoolean IsActive() const
Determine if the authorisation is to be applied.
PHTTPRequest::entityBody
PString entityBody
original entity body (POST only)
Definition: http.h:987
PHTTPFile
This object describes a HyperText Transport Protocol resource which is a single file.
Definition: http.h:1614
PHTTPClientAuthentication::GetAuthRealm
virtual PString GetAuthRealm() const
Definition: http.h:299
PHTTPSpace::Node::parent
Node * parent
Definition: http.h:143
PHTTP::RequestOK
200 - request has succeeded
Definition: http.h:181
ipsock.h
PHTTP::SwitchingProtocols
101 - upgrade allowed
Definition: http.h:180
PHTTPConnectionInfo::GetMajorVersion
int GetMajorVersion() const
Definition: http.h:684
PHTTPString::PHTTPString
PHTTPString(const PURL &url)
Contruct a new simple string resource for the HTTP space.
PHTTPString
This object describes a HyperText Transport Protocol resource which is a string kept in memory...
Definition: http.h:1525
PHTTPConnectionInfo::persistenceMaximum
unsigned persistenceMaximum
Definition: http.h:731
PHTTPDirRequest::fakeIndex
PString fakeIndex
Definition: http.h:1913
PHTTP::GET
Definition: http.h:170
PHTTPClient::m_authentication
PHTTPClientAuthentication * m_authentication
Definition: http.h:652
PHTTPConnectionInfo::GetMIME
const PMIMEInfo & GetMIME() const
Definition: http.h:676
PHTTPSimpleAuth::realm
PString realm
Definition: http.h:1128
PHTTPSpace::StartWrite
void StartWrite() const
This function attempts to acquire the mutex for writing.
Definition: http.h:122
PHTTPResource::GetExpirationDate
virtual PBoolean GetExpirationDate(PTime &when)
Get a block of data (eg HTML) that the resource contains.
PHTTPConnectionInfo::GetEntityBodyLength
long GetEntityBodyLength() const
Definition: http.h:687
PHTTP::UnAuthorised
401 - request requires authentication
Definition: http.h:195
PHTTPDirRequest::PHTTPDirRequest
PHTTPDirRequest(const PURL &url, const PMIMEInfo &inMIME, const PMultiPartList &multipartFormInfo, PHTTPResource *resource, PHTTPServer &server)
PHTTPResource
This object describes a HyperText Transport Protocol resource.
Definition: http.h:1222
PHTTPSimpleAuth::PHTTPSimpleAuth
PHTTPSimpleAuth(const PString &realm, const PString &username, const PString &password)
PHTTPClientBasicAuthentication::PHTTPClientBasicAuthentication
PHTTPClientBasicAuthentication()
PHTTP::NotFound
404 - resource cannot be found
Definition: http.h:198
PHTTPServer::SetURLSpace
void SetURLSpace(const PHTTPSpace &space)
Use a new URL name space for this HTTP socket.
PHTTPClientDigestAuthentication::Compare
virtual Comparison Compare(const PObject &other) const
Compare the two objects and return their relative rank.
PHTTPMultiSimpAuth::PHTTPMultiSimpAuth
PHTTPMultiSimpAuth(const PString &realm)
PCollection::RemoveAll
virtual void RemoveAll()
Remove all of the elements in the collection.
PHTTP::ForwardedTag
static const PCaselessString & ForwardedTag()
PHTTPClientDigestAuthentication::GetOpaque
const PString & GetOpaque() const
Definition: http.h:396
PHTTPTailFile::LoadHeaders
virtual PBoolean LoadHeaders(PHTTPRequest &request)
Get the headers for block of data (eg HTML) that the resource contains.
PHTTPDirectory
This object describes a HyperText Transport Protocol resource which is a set of files in a directory...
Definition: http.h:1819
PInternetProtocol
A TCP/IP socket for process/application layer high level protocols.
Definition: inetprot.h:62
PHTTP::DELETE
Definition: http.h:172
PAbstractArray
This class contains a variable length array of arbitrary memory blocks.
Definition: array.h:67
PHTTPClientAuthentication::GetAuthParam
PString GetAuthParam(const PString &auth, const char *name) const
PHTTP::MovedTemporarily
302 - resource moved temporarily: location field has new URL
Definition: http.h:190
PHTTPSpace::Node::children
ChildList children
Definition: http.h:144
PHTTPDirectory::CreateRequest
virtual PHTTPRequest * CreateRequest(const PURL &url, const PMIMEInfo &inMIME, const PMultiPartList &multipartFormInfo, PHTTPServer &socket)
Create a new request block for this type of resource.
PHTTPConnectionInfo::entityBodyLength
long entityBodyLength
Definition: http.h:729
PHTTPClient::PutTextDocument
bool PutTextDocument(const PURL &url, const PString &document, const PString &contentType=PMIMEInfo::TextPlain())
Put the document specified by the URL.
PBoolean
BOOL PBoolean
Definition: object.h:102
PHTTPString::LoadHeaders
virtual PBoolean LoadHeaders(PHTTPRequest &request)
Get the headers for block of data (eg HTML) that the resource contains.
PDirectory
Class to represent a directory in the operating system file system.
Definition: pdirect.h:182
PHTTPConnectionInfo::GetCommandName
const PString & GetCommandName() const
Definition: http.h:672
PHTTP::PaymentRequired
402 - reserved
Definition: http.h:196
PHTTPClient::PostData
bool PostData(const PURL &url, const PStringToString &data)
Post the "application/x-www-form-urlencoded" data specified to the URL.
PHTTPServer::GetConnectionInfo
PHTTPConnectionInfo & GetConnectionInfo()
Get the connection info for this connection.
Definition: http.h:949
PHTTPClientAuthentication::AsHex
PString AsHex(PMessageDigest5::Code &digest) const
PHTTPAuthority::DecodeBasicAuthority
static void DecodeBasicAuthority(const PString &authInfo, PString &username, PString &password)
PHTTPClientAuthenticator
Definition: http.h:320
PBYTEArray
Array of unsigned characters.
Definition: array.h:670
PHTTPSpace::Node::Node
Node(const PString &name, Node *parentNode)
PHTTPServer::OnProxy
virtual PBoolean OnProxy(const PHTTPConnectionInfo &conInfo)
Handle a proxy command request from a client.
PHTTPClientAuthentication::password
PString password
Definition: http.h:315
PHTTPClientDigestAuthentication::PHTTPClientDigestAuthentication
PHTTPClientDigestAuthentication()
PAtomicInteger
This class implements an integer that can be atomically incremented and decremented in a thread-safe ...
Definition: critsec.h:171
PHTTP::MethodNotAllowed
405 - not allowed on this resource
Definition: http.h:199
PHTTP::Gone
410 - resource gone away
Definition: http.h:204
PHTTPRequest::url
const PURL & url
Universal Resource Locator for document.
Definition: http.h:982
PHTTPConnectionInfo::GetPersistenceTimeout
PTimeInterval GetPersistenceTimeout() const
Get the maximum time a persistent connection may persist.
Definition: http.h:691
PHTTPClientDigestAuthentication::Algorithm_MD5
Definition: http.h:391
PHTTPResource::OnGET
virtual PBoolean OnGET(PHTTPServer &server, const PURL &url, const PMIMEInfo &info, const PHTTPConnectionInfo &conInfo)
Handle the GET command passed from the HTTP socket.
mime.h
PHTTPConnectionInfo::DecodeMultipartFormInfo
bool DecodeMultipartFormInfo()
Definition: http.h:717
PHTTPServer::OnUnknown
virtual PBoolean OnUnknown(const PCaselessString &command, const PHTTPConnectionInfo &connectInfo)
Handle an unknown command.
PHTTPClientAuthentication::Parse
virtual PBoolean Parse(const PString &auth, PBoolean proxy)=0
PHTTPRequest::contentSize
PINDEX contentSize
Size of the body of the resource data.
Definition: http.h:988
PHTTPConnectionInfo::minorVersion
int minorVersion
Definition: http.h:727
PHTTPClient::PHTTPClient
PHTTPClient(const PString &userAgentName=PString::Empty())
Create a new HTTP client channel.
PHTTPRequest::localAddr
PIPSocket::Address localAddr
IP address of local interface for request.
Definition: http.h:990
PHTTPResource::~PHTTPResource
virtual ~PHTTPResource()
PHTTPString::GetString
const PString & GetString()
Get the string for this resource.
Definition: http.h:1592
PHTTPClient
A TCP/IP socket for the HyperText Transfer Protocol version 1.0.
Definition: http.h:436
PHTTPResource::GetURL
const PURL & GetURL() const
Get the URL for this resource.
Definition: http.h:1257
PHTTPFile::PHTTPFile
PHTTPFile(const PString &filename)
Contruct a new simple file resource for the HTTP space.
PHTTP::UserAgentTag
static const PCaselessString & UserAgentTag()
PFACTORY_LOAD
PFACTORY_LOAD(PURL_HttpLoader)
PHTTP::FromTag
static const PCaselessString & FromTag()
PHTTPResource::baseURL
PURL baseURL
Base URL for the resource, may accept URLS with a longer hierarchy.
Definition: http.h:1511
PHTTP::NoContent
204 - no new information
Definition: http.h:185
PHTTPDirectory::LoadText
virtual PString LoadText(PHTTPRequest &request)
Get a block of text data (eg HTML) that the resource contains.
PHTTP::MIMEVersionTag
static const PCaselessString & MIMEVersionTag()
PHTTPClientAuthenticator::PHTTPClientAuthenticator
PHTTPClientAuthenticator(const PString &cmdName, const PString &uri, PMIMEInfo &mime, const PString &body)
PHTTPClientBasicAuthentication::Parse
virtual PBoolean Parse(const PString &auth, PBoolean proxy)
PHTTPServer::ProcessCommand
virtual PBoolean ProcessCommand()
Process commands, dispatching to the appropriate virtual function.
PHTTPConnectionInfo::IsCompatible
PBoolean IsCompatible(int major, int minor) const
PHTTPDirectory::AllowDirectories
void AllowDirectories(PBoolean enable=true)
Enable or disable directory listings when a default directory file does not exist.
PHTTPConnectionInfo::ResetMultipartFormInfo
void ResetMultipartFormInfo()
Definition: http.h:710
PHTTP::PHTTP
PHTTP()
Create a TCP/IP HTTP protocol channel.
PHTTPClient::m_persist
bool m_persist
Definition: http.h:649
PHTTPServer::urlSpace
PHTTPSpace urlSpace
Definition: http.h:954
PHTTP::ChunkedTag
static const PCaselessString & ChunkedTag()
PHTTPClientDigestAuthentication::cnonce
PString cnonce
Definition: http.h:408
PHTTPDirectory::authorisationRealm
PString authorisationRealm
Definition: http.h:1896
PHTTP::ParseResponse
virtual PINDEX ParseResponse(const PString &line)
Parse a response line string into a response code and any extra info on the line. ...
PHTTPClient::AssureConnect
bool AssureConnect(const PURL &url, PMIMEInfo &outMIME)
PHTTPClientAuthentication::AuthObject::~AuthObject
virtual ~AuthObject()
Definition: http.h:273
PHTTPRequest::origin
PIPSocket::Address origin
IP address of origin host for request.
Definition: http.h:989
PHTTPSpace::mutex
PReadWriteMutex * mutex
Definition: http.h:132
PHTTPConnectionInfo::SetPersistenceTimeout
void SetPersistenceTimeout(const PTimeInterval &t)
Set the maximum time a persistent connection may persist.
Definition: http.h:695
PHTTPAuthority::Validate
virtual PBoolean Validate(const PHTTPRequest &request, const PString &authInfo) const =0
Validate the user and password provided by the remote HTTP client for the realm specified by the clas...
PHTTPResource::ClearAuthority
void ClearAuthority()
Set the current authority for the resource to unrestricted.
PHTTP::UseProxy
305 - proxy redirect
Definition: http.h:193
PHTTPDirectory::basePath
PDirectory basePath
Definition: http.h:1895
PHTTPClientDigestAuthentication::opaque
PString opaque
Definition: http.h:403
PHTTPClientAuthenticator::m_method
PString m_method
Definition: http.h:334
PString
The character string class.
Definition: pstring.h:108
PHTTPServer::connectInfo
PHTTPConnectionInfo connectInfo
Definition: http.h:955
PHTTPClientAuthentication::AuthObject
Definition: http.h:271
PHTTPClientDigestAuthentication::nonceCount
PAtomicInteger nonceCount
Definition: http.h:409
PHTTP::PragmaTag
static const PCaselessString & PragmaTag()
PHTTP::Conflict
409 - resource conflict on action
Definition: http.h:203
PHTTP::LastModifiedTag
static const PCaselessString & LastModifiedTag()
PHTTPClient::PutDocument
bool PutDocument(const PURL &url, PMIMEInfo &outMIME, PMIMEInfo &replyMIME)
Put the document specified by the URL.
PString::Empty
static PString Empty()
Return an empty string.
PHTTPFile::filePath
PFilePath filePath
Definition: http.h:1709
PHTTPRequest::localPort
WORD localPort
Port number of local server for request.
Definition: http.h:991
PHTTPConnectionInfo::persistenceTimeout
PTimeInterval persistenceTimeout
Definition: http.h:730
PHTTP::MultipleChoices
300 - requested resource available elsewehere
Definition: http.h:188
PCONTAINERINFO
#define PCONTAINERINFO(cls, par)
Macro to declare funtions required in a container.
Definition: contain.h:343
PHTTP::LengthRequired
411 - no Content-Length
Definition: http.h:205
PHTTPClientDigestAuthentication::GetAuthRealm
virtual PString GetAuthRealm() const
Definition: http.h:387
PHTTPResource::OnPOST
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.
PHTTPResource::PHTTPResource
PHTTPResource(const PURL &url)
PHTTP::NotModified
304 - document has not been modified
Definition: http.h:192
PHTTPClientDigestAuthentication::nonce
PString nonce
Definition: http.h:401
PHTTPDirectory::FindAuthorisations
PBoolean FindAuthorisations(const PDirectory &dir, PString &realm, PStringToString &authorisations)
PHTTPRequest::code
PHTTP::StatusCode code
Status code for OnError() reply.
Definition: http.h:985
PHTTPResource::LoadText
virtual PString LoadText(PHTTPRequest &request)
Get a block of text data (eg HTML) that the resource contains.
PContainer
Abstract class to embody the base functionality of a container.
Definition: contain.h:104
PHTTPResource::IsModifiedSince
virtual PBoolean IsModifiedSince(const PTime &when)
Check to see if the resource has been modified since the date specified.
PHTTPMultiSimpAuth
This class describes the simple authorisation mechanism for a Universal Resource Locator, a fixed realm, multiple usernames and passwords.
Definition: http.h:1140
PHTTPConnectionInfo::isPersistent
bool isPersistent
Definition: http.h:723
PHTTP::ContentTypeTag
static const PCaselessString & ContentTypeTag()
Definition: http.h:219
PHTTPSpace::AddOptions
AddOptions
Definition: http.h:67
PHTTPSpace::Node::~Node
~Node()
PHTTPSpace
This class describes a name space that a Universal Resource Locator operates in.
Definition: http.h:58
PHTTPFile::LoadHeaders
virtual PBoolean LoadHeaders(PHTTPRequest &request)
Get the headers for block of data (eg HTML) that the resource contains.
PHTTPClient::SetPersistent
void SetPersistent(bool persist=true)
Set persistent connection mode.
Definition: http.h:634
PHTTPTailFile::PHTTPTailFile
PHTTPTailFile(const PString &filename)
Contruct a new simple file resource for the HTTP space.
PHTTPServer::OnGET
virtual PBoolean OnGET(const PURL &url, const PMIMEInfo &info, const PHTTPConnectionInfo &conInfo)
Handle a GET command from a client.
PHTTPResource::OnHEAD
virtual PBoolean OnHEAD(PHTTPServer &server, const PURL &url, const PMIMEInfo &info, const PHTTPConnectionInfo &conInfo)
Handle the HEAD command passed from the HTTP socket.
PHTTPConnectionInfo::IsPersistent
bool IsPersistent() const
Definition: http.h:681
PHTML
This class describes a HyperText markup Language string as used by the World Wide Web and the PURL an...
Definition: html.h:49
PHTTP::CONNECT
Definition: http.h:174
PHTTPConnectionInfo::mimeInfo
PMIMEInfo mimeInfo
Definition: http.h:722
PHTTPResource::OnPOSTData
virtual PBoolean OnPOSTData(PHTTPRequest &request, const PStringToString &data)
Send the data associated with a POST command.
PHTTPSpace::PHTTPSpace
PHTTPSpace()
Constructor for HTTP URL Name Space.
PFactory
Template class for generic factories of an abstract class.
Definition: pfactory.h:144
PHTTP::TRACE
Definition: http.h:172
PIPSocket::Address
A class describing an IP address.
Definition: ipsock.h:75
PHTTPClientAuthenticationFactory
PFactory< PHTTPClientAuthentication > PHTTPClientAuthenticationFactory
Definition: http.h:318
PHTTP::OPTIONS
Definition: http.h:172
PHTTPServer::Construct
void Construct()
PHTTPClient::WriteCommand
bool WriteCommand(Commands cmd, const PString &url, PMIMEInfo &outMIME, const PString &dataBody)
Write a HTTP command to server.
PHTTPConnectionInfo::m_multipartFormInfo
PMultiPartList m_multipartFormInfo
Definition: http.h:732
PHTTPFile::CreateRequest
virtual PHTTPRequest * CreateRequest(const PURL &url, const PMIMEInfo &inMIME, const PMultiPartList &multipartFormInfo, PHTTPServer &socket)
Create a new request block for this type of resource.
PHTTPClientDigestAuthentication::qopAuthInt
bool qopAuthInt
Definition: http.h:406
PHTTP::KeepAliveTag
static const PCaselessString & KeepAliveTag()
PReadWriteMutex::EndWrite
void EndWrite()
This function attempts to release the mutex for writing.
PHTTPConnectionInfo::GetMinorVersion
int GetMinorVersion() const
Definition: http.h:685
PHTTPClient::GetTextDocument
bool GetTextDocument(const PURL &url, PString &document, const PString &contentType=PString::Empty())
Get the document specified by the URL.
PHTTPMultiSimpAuth::IsActive
virtual PBoolean IsActive() const
Determine if the authirisation is to be applied.
PHTTPClientAuthenticator::m_body
PString m_body
Definition: http.h:337
PHTTPRequest::server
PHTTPServer & server
Server channel that request initiated on.
Definition: http.h:981
PHTTPServer::OnError
virtual PBoolean OnError(StatusCode code, const PCaselessString &extra, const PHTTPConnectionInfo &connectInfo)
Write an error response for the specified code.
PHTTPResource::GetHitCount
DWORD GetHitCount() const
Get the current hit count for the resource.
Definition: http.h:1290
PHTTP::Forbidden
403 - request is refused due to unsufficient authorisation
Definition: http.h:197
PHTTPResource::CreateRequest
virtual PHTTPRequest * CreateRequest(const PURL &url, const PMIMEInfo &inMIME, const PMultiPartList &multipartFormInfo, PHTTPServer &socket)
Create a new request block for this type of resource.
PHTTPSimpleAuth::GetUserName
const PString & GetUserName() const
Get the user name allocated to this simple authorisation.
Definition: http.h:1117
PHTTP::StatusCode
StatusCode
Definition: http.h:178
PHTTPResource::OnGETData
virtual PBoolean OnGETData(PHTTPServer &server, const PURL &url, const PHTTPConnectionInfo &connectInfo, PHTTPRequest &request)
Send the data associated with a GET command.
PHTTP::ConnectionTag
static const PCaselessString & ConnectionTag()
PHTTPClient::m_userName
PString m_userName
Definition: http.h:650
PHTTP::ProxyAuthenticateTag
static const PCaselessString & ProxyAuthenticateTag()
PHTTP::RequestTimeout
408 - server timeout on request
Definition: http.h:202
PHTTP::NoneAcceptable
406 - encoding not acceptable
Definition: http.h:200
PHTTPFile::LoadData
virtual PBoolean LoadData(PHTTPRequest &request, PCharArray &data)
Get a block of data that the resource contains.
PHTTPRequest::PHTTPRequest
PHTTPRequest(const PURL &url, const PMIMEInfo &inMIME, const PMultiPartList &multipartFormInfo, PHTTPResource *resource, PHTTPServer &server)
PReadWriteMutex
This class defines a thread synchronisation object.
Definition: syncthrd.h:251
PHTTPTailFile::LoadData
virtual PBoolean LoadData(PHTTPRequest &request, PCharArray &data)
Get a block of data that the resource contains.
PHTTPResource::contentType
PString contentType
MIME content type for the resource.
Definition: http.h:1512
PHTTPSpace::DelResource
PBoolean DelResource(const PURL &url)
Delete an existing resource to the URL space.
PHTTP::IfModifiedSinceTag
static const PCaselessString & IfModifiedSinceTag()
PHTTPConnectionInfo::GetMultipartFormInfo
const PMultiPartList & GetMultipartFormInfo() const
Definition: http.h:707
PInternetProtocol::ReadResponse
virtual PBoolean ReadResponse()
Read a response code followed by a text string describing the response to a command.
PHTTP::Accepted
202 - request accepted, but not yet completed
Definition: http.h:183
PHTTPConnectionInfo::GetURL
const PURL & GetURL() const
Definition: http.h:674
PHTTPClientBasicAuthentication
Definition: http.h:342
PHTTPConnectionInfo::isProxyConnection
bool isProxyConnection
Definition: http.h:725
PHTTPClientAuthentication::ParseAuthenticationRequired
static PHTTPClientAuthentication * ParseAuthenticationRequired(bool isProxy, const PMIMEInfo &line, PString &errorMsg)
PHTTPResource::SendData
virtual void SendData(PHTTPRequest &request)
Send the data associated with a command.
PHTTPClientAuthentication::AuthObject::GetMethod
virtual PString GetMethod()=0
PHTTPConnectionInfo::url
PURL url
Definition: http.h:721
PHTTPClientDigestAuthentication::qopAuth
bool qopAuth
Definition: http.h:405
PHTTP::BadGateway
502 - error whilst acting as gateway
Definition: http.h:209
PHTTPConnectionInfo::GetPersistenceMaximumTransations
unsigned GetPersistenceMaximumTransations() const
Get the maximum number of transations (GET/POST etc) for persistent connection.
Definition: http.h:700
PHTTPConnectionInfo::GetEntityBody
PString GetEntityBody() const
Definition: http.h:713
PHTTPClientBasicAuthentication::Authorise
virtual PBoolean Authorise(AuthObject &pdu) const
PHTTPServer::transactionCount
unsigned transactionCount
Definition: http.h:956
PHTTPServer::nextTimeout
PTimeInterval nextTimeout
Definition: http.h:957
PHTTPClientAuthentication::Authorise
virtual PBoolean Authorise(AuthObject &pdu) const =0
PHTTP::DateTag
static const PCaselessString & DateTag()
PHTTPClientAuthentication::AuthObject::GetURI
virtual PString GetURI()=0
PHTTPClientDigestAuthentication::authRealm
PString authRealm
Definition: http.h:400
PHTTP::HEAD
Definition: http.h:170
PHTTP::ProxyAuthenticationRequired
407 - must authenticate with proxy first
Definition: http.h:201
PHTTPResource::OnLoadedText
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 load...
PHTTPClientAuthentication::username
PString username
Definition: http.h:314
PHTTPRequest::outMIME
PMIMEInfo outMIME
MIME information used in reply.
Definition: http.h:986
PMIMEInfo::TextPlain
static const PCaselessString & TextPlain()
PHTTPServer
A TCP/IP socket for the HyperText Transfer Protocol version 1.0.
Definition: http.h:762
PHTTP
A common base class for TCP/IP socket for the HyperText Transfer Protocol version 1...
Definition: http.h:162
PHTTPRequest
This object describes a HyperText Transport Protocol request.
Definition: http.h:968
url.h
PObject
Ultimate parent class for all objects in the class library.
Definition: object.h:1118
PHTTPConnectionInfo
This object describes the connectiono associated with a HyperText Transport Protocol request...
Definition: http.h:665
PHTTP::PartialContent
206 - partial GET succeeded
Definition: http.h:187
PHTTPMultiSimpAuth::realm
PString realm
Definition: http.h:1211
PHTTP::Commands
Commands
Definition: http.h:168
PURL
This class describes a Universal Resource Locator.
Definition: url.h:54
PHTTP::Continue
100 - Continue
Definition: http.h:179
PHTTP::AllowTag
static const PCaselessString & AllowTag()
PHTTPClientAuthentication::GetUsername
virtual PString GetUsername() const
Definition: http.h:297
PHTTPConnectionInfo::majorVersion
int majorVersion
Definition: http.h:726
PHTTPAuthority::GetRealm
virtual PString GetRealm(const PHTTPRequest &request) const =0
Get the realm or name space for the user authorisation name and password as required by the basic aut...
PHTTP::BadRequest
400 - request malformed or not understood
Definition: http.h:194
PHTTPRequest::m_resource
PHTTPResource * m_resource
HTTP resource found for the request.
Definition: http.h:992
PHTTPClientDigestAuthentication::GetAlgorithm
Algorithm GetAlgorithm() const
Definition: http.h:395
PHTTPFile::LoadText
virtual PString LoadText(PHTTPRequest &request)
Get a block of text data (eg HTML) that the resource contains.
PHTTPConnectionInfo::GetCommandCode
PHTTP::Commands GetCommandCode() const
Definition: http.h:671
PMessageDigest5::Code
Definition: cypher.h:341
PHTTPClientDigestAuthentication::GetStale
bool GetStale() const
Definition: http.h:397
PHTTPClientDigestAuthentication::algorithm
Algorithm algorithm
Definition: http.h:402
PHTTPDirectory::PHTTPDirectory
PHTTPDirectory(const PURL &url, const PDirectory &dir)
PHTTPClientAuthenticator::GetMIME
virtual PMIMEInfo & GetMIME()
PHTTPClientAuthentication::PHTTPClientAuthentication
PHTTPClientAuthentication()
PHTTPServer::ReadEntityBody
virtual PString ReadEntityBody()
Read the entity body associated with a HTTP request, and close the socket if not a persistent connect...
PHTTPTailFile
This object describes a HyperText Transport Protocol resource which is a single file.
Definition: http.h:1740
PHTTPMultiSimpAuth::users
PStringToString users
Definition: http.h:1212
PHTTPClient::SetAuthenticationInfo
void SetAuthenticationInfo(const PString &userName, const PString &password)
Set authentication paramaters to be use for retreiving documents.
PHTTP::Created
201 - new resource created: entity body contains URL
Definition: http.h:182
PHTTPClientDigestAuthentication::NumAlgorithms
Definition: http.h:392
PHTTPRequest::inMIME
const PMIMEInfo & inMIME
Extra MIME information in command.
Definition: http.h:983
PHTTPClientAuthentication::SetAuthRealm
virtual void SetAuthRealm(const PString &)
Definition: http.h:303
PHTTPSimpleAuth::Validate
virtual PBoolean Validate(const PHTTPRequest &request, const PString &authInfo) const
Validate the user and password provided by the remote HTTP client for the realm specified by the clas...
PHTTPClientAuthenticator::GetMethod
virtual PString GetMethod()
PHTTPResource::LoadHeaders
virtual PBoolean LoadHeaders(PHTTPRequest &request)=0
Get the headers for block of data (eg HTML) that the resource contains.
PHTTP::GatewayTimeout
504 - timeout whilst talking to gateway
Definition: http.h:211