|
| PHTTPServer () |
| Create a TCP/IP HTTP protocol socket channel. More...
|
|
| PHTTPServer (const PHTTPSpace &urlSpace) |
|
virtual PString | GetServerName () const |
| Get the name of the server. More...
|
|
PHTTPSpace & | GetURLSpace () |
| Get the name space being used by the HTTP server socket. More...
|
|
void | SetURLSpace (const PHTTPSpace &space) |
| Use a new URL name space for this HTTP socket. More...
|
|
virtual PBoolean | ProcessCommand () |
| Process commands, dispatching to the appropriate virtual function. More...
|
|
virtual PBoolean | OnGET (const PURL &url, const PMIMEInfo &info, const PHTTPConnectionInfo &conInfo) |
| Handle a GET command from a client. More...
|
|
virtual PBoolean | OnHEAD (const PURL &url, const PMIMEInfo &info, const PHTTPConnectionInfo &conInfo) |
| Handle a HEAD command from a client. More...
|
|
virtual PBoolean | OnPOST (const PURL &url, const PMIMEInfo &info, const PStringToString &data, const PHTTPConnectionInfo &conInfo) |
| Handle a POST command from a client. More...
|
|
virtual PBoolean | OnProxy (const PHTTPConnectionInfo &conInfo) |
| Handle a proxy command request from a client. More...
|
|
virtual PString | ReadEntityBody () |
| Read the entity body associated with a HTTP request, and close the socket if not a persistent connection. More...
|
|
virtual PBoolean | OnUnknown (const PCaselessString &command, const PHTTPConnectionInfo &connectInfo) |
| Handle an unknown command. More...
|
|
PBoolean | StartResponse (StatusCode code, PMIMEInfo &headers, long bodySize) |
| Write a command reply back to the client, and construct some of the outgoing MIME fields. More...
|
|
virtual PBoolean | OnError (StatusCode code, const PCaselessString &extra, const PHTTPConnectionInfo &connectInfo) |
| Write an error response for the specified code. More...
|
|
void | SetDefaultMIMEInfo (PMIMEInfo &info, const PHTTPConnectionInfo &connectInfo) |
| Set the default mime info. More...
|
|
PHTTPConnectionInfo & | GetConnectionInfo () |
| Get the connection info for this connection. More...
|
|
virtual bool | OnCommand (PINDEX cmd, const PURL &url, const PString &args, PHTTPConnectionInfo &connectInfo) |
| Called when a request is received. More...
|
|
|
enum | Commands {
GET,
HEAD,
POST,
PUT,
DELETE,
TRACE,
OPTIONS,
CONNECT,
NumCommands
} |
|
enum | StatusCode {
BadResponse = 1,
ContentProcessorError,
UnknownTransferEncoding,
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
} |
|
static const PCaselessString & | HostTag () |
|
static const PCaselessString & | AllowTag () |
|
static const PCaselessString & | AuthorizationTag () |
|
static const PCaselessString & | ContentEncodingTag () |
|
static const PCaselessString & | ContentLengthTag () |
|
static const PCaselessString & | 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 () |
|
enum | StuffState {
DontStuff,
StuffIdle,
StuffCR,
StuffCRLF,
StuffCRLFdot,
StuffCRLFdotCR
} |
|
A TCP/IP socket for the HyperText Transfer Protocol version 1.0.
The server socket thread would continuously call the ProcessCommand() function until it returns false. This will then call the appropriate virtual function on parsing the HTTP protocol.
PTCPSocket socket(80);
if (!socket.Listen())
return;
PHTTPSpace httpNameSpace;
httpNameSpace.AddResource(new PHTTPDirectory("data", "data"))
PHTTServer httpServer(httpNameSpace);
if (!httpServer.Open(socket))
return;
while (httpServer.ProcessCommand())
;
Write a command reply back to the client, and construct some of the outgoing MIME fields.
The MIME fields are not sent.
The bodySize
parameter determines the size of the entity body associated with the response. If bodySize
is >= 0, then a ContentLength field will be added to the outgoing MIME headers if one does not already exist.
If bodySize
is < 0, then it is assumed that the size of the entity body is unknown, or has already been added, and no ContentLength field will be constructed.
If the version of the request is less than 1.0, then this function does nothing.
- Returns
- true if requires v1.1 chunked transfer encoding.
- Parameters
-
code | Status code for the response. |
headers | MIME variables included in response. |
bodySize | Size of the rest of the response. |