# PHTTPDirectory Class Reference

This object describes a HyperText Transport Protocol resource which is a set of files in a directory. More...

`#include <http.h>`

Inheritance diagram for PHTTPDirectory:

List of all members.

## Public Member Functions

| PHTTPDirectory (const PURL &url, const PDirectory &dir)
| PHTTPDirectory (const PURL &url, const PDirectory &dir, const PHTTPAuthority &auth)
virtual PHTTPRequest * | CreateRequest (const PURL &url, const PMIMEInfo &inMIME, const PMultiPartList &multipartFormInfo, PHTTPServer &socket)
| Create a new request block for this type of resource.
virtual PBoolean | LoadHeaders (PHTTPRequest &request)
| Get the headers for block of data (eg HTML) that the resource contains.
virtual PString | LoadText (PHTTPRequest &request)
| Get a block of text data (eg HTML) that the resource contains.
void | EnableAuthorisation (const PString &realm)
| Enable or disable access control using .access files.
void | AllowDirectories (PBoolean enable=true)
| Enable or disable directory listings when a default directory file does not exist.

## Protected Member Functions

PBoolean | CheckAuthority (PHTTPServer &server, const PHTTPRequest &request, const PHTTPConnectionInfo &conInfo)
| See if the resource is authorised given the mime info.
PBoolean | FindAuthorisations (const PDirectory &dir, PString &realm, PStringToString &authorisations)

## Protected Attributes

PDirectory | basePath
PString | authorisationRealm
PBoolean | allowDirectoryListing

## Detailed Description

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.

## Constructor & Destructor Documentation

PHTTPDirectory::PHTTPDirectory | ( | const PURL & | url,
|  | const PDirectory & | dir |
| ) |  |  |

Parameters:

  url | Name of the resource in URL space.
  dir | Location of file in file system.

PHTTPDirectory::PHTTPDirectory | ( | const PURL & | url,
|  | const PDirectory & | dir,
|  | const PHTTPAuthority & | auth |
| ) |  |  |

Parameters:

  url | Name of the resource in URL space.
  dir | Location of file in file system.
  auth | Authorisation for the resource.

## Member Function Documentation

void PHTTPDirectory::AllowDirectories | ( | PBoolean | enable = `true` | ) |

Enable or disable directory listings when a default directory file does not exist.

PBoolean PHTTPDirectory::CheckAuthority | ( | PHTTPServer & | server,
|  | const PHTTPRequest & | request,
|  | const PHTTPConnectionInfo & | conInfo |
| ) |  |  | `[protected, virtual]`

See if the resource is authorised given the mime info.

Reimplemented from PHTTPResource.

virtual PHTTPRequest* PHTTPDirectory::CreateRequest | ( | const PURL & | url,
|  | const PMIMEInfo & | inMIME,
|  | const PMultiPartList & | multipartFormInfo,
|  | PHTTPServer & | socket |
| ) |  |  | `[virtual]`

Create a new request block for this type of resource.

Returns:
  Pointer to instance of PHTTPRequest descendant class.

Reimplemented from PHTTPFile.

void PHTTPDirectory::EnableAuthorisation | ( | const PString & | realm | ) |

Enable or disable access control using .access files.

A directory tree containing a _access file will require authorisation to allow access. This file has contains one or more lines, each containing a username and password seperated by a ":" character.

The parameter sets the realm used for authorisation requests. An empty realm disables auhtorisation.

PBoolean PHTTPDirectory::FindAuthorisations | ( | const PDirectory & | dir,
|  | PString & | realm,
|  | PStringToString & | authorisations |
| ) |  |  | `[protected]`

virtual PBoolean PHTTPDirectory::LoadHeaders | ( | PHTTPRequest & | request | ) | `[virtual]`

Get the headers for block of data (eg HTML) that the resource contains.

This will fill in all the fields of the `outMIME` parameter required by the resource and return the status for the load.

Returns:
  true if all OK, false if an error occurred.

Parameters:

  request | Information on this request.

Reimplemented from PHTTPFile.

virtual PString PHTTPDirectory::LoadText | ( | PHTTPRequest & | request | ) | `[virtual]`

Get a block of text data (eg HTML) that the resource contains.

The default behaviour is to assert, one of `LoadText()` or `LoadData()` functions must be overridden for correct operation.

Returns:
  String for loaded text.

Parameters:

  request | Information on this request.

Reimplemented from PHTTPFile.

## Member Data Documentation

PBoolean PHTTPDirectory::allowDirectoryListing `[protected]`

PString PHTTPDirectory::authorisationRealm `[protected]`

PDirectory PHTTPDirectory::basePath `[protected]`

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

- http.h