NAME
Any::Daemon::HTTP::Directory - describe a server directory
INHERITANCE
Any::Daemon::HTTP::Directory is extended by
Any::Daemon::HTTP::UserDirs
SYNOPSIS
# implicit creation of ::Directory object
my $vh = Any::Daemon::HTTP::VirtualHost
->new(directories => {path => '/', location => ...})
my $vh = Any::Daemon::HTTP::VirtualHost
->new(directories => [ \%dir1, \%dir2, $dir_obj ])
# explicit use
my $root = Any::Daemon::HTTP::Directory
->new(path => '/', location => '...');
my $vh = Any::Daemon::HTTP::VirtualHost
->new(directories => $root);
DESCRIPTION
Each Any::Daemon::HTTP::VirtualHost will define where the files are located. Parts of the URI path can map on different directories, with different permissions.
User directories, like used in the URI <http://xx/~user/yy
> are implemented in Any::Daemon::HTTP::UserDirs.
METHODS
Constructors
- Any::Daemon::HTTP::Directory->new(OPTIONS|HASH-of-OPTIONS)
-
-Option --Default allow <undef> deny <undef> directory_list <false> index_file ['index.html', 'index.htm'] location <required> path '/'
- allow => CIDR|HOSTNAME|DOMAIN|CODE|ARRAY
-
Allow all requests which pass any of these parameters, and none of the deny parameters. See "Allow access". Be warned that the access rights are not inherited from directory configurations encapsulating this one.
- deny => CIDR|HOSTNAME|DOMAIN|CODE|ARRAY
-
See
allow
and "Allow access" - directory_list => BOOLEAN
-
Enables the display of a directory, when it does not contain one of the
index_file
prepared defaults. - index_file => STRING|ARRAY
-
When a directory is addressed, it is scanned whether one of these files exist. If so, the content will be shown.
- location => DIRECTORY|CODE
-
The DIRECTORY to be prefixed before the path of the URI, or a CODE reference which will rewrite the path (passed as only parameter) into the absolute file or directory name.
- path => PATH
-
If the directory PATH (relative to the document root
location
) is not trailed by a '/', it will be made so.
Attributes
Permissions
- $obj->allow(SESSION, REQUEST, URI)
-
BE WARNED that the URI is the rewrite of the REQUEST uri, and therefore you should use that URI. The SESSION represents a user.
See "Allow access".
- $obj->filename(PATH)
-
Convert a URI PATH into a directory path. Return
undef
if not possible. - $obj->fromDisk(SESSION, REQUEST, URI)
-
Try to produce a response (HTTP::Response) for something inside this directory structure.
undef
is returned if nothing useful is found. - $obj->list(DIRECTORY, OPTIONS)
-
Returns a HASH with information about the DIRECTORY content. This may be passed into some template or the default template. See "Return of directoryList" about the returned output.
-Option --Default filter <undef> hide_symlinks <false> names <skip hidden files>
- filter => CODE
-
For each of the selected names (see
names
option) the lstat() is called. That data is expanded into a HASH, but not all additional fields are yet filled-in (only the ones which come for free). - hide_symlinks => BOOLEAN
- names => CODE|Regexp
-
Reduce the returned list. The CODE reference is called with the found filename, and should return true when the name is acceptable. The default regexp (on UNIX) is
qr/^[^.]/
DETAILS
Directory limits
Allow access
The allow() method handles access rights. When a trueth value is produced, then access is permitted.
The base class implements access rules via the allow
or deny
option of new(). These parameters are exclusive (which is slightly different from Apache); you can either allow or deny, but not both at the same time. Be warned that the access rights are also not inherited from directory configurations encapsulating this one.
The parameters to allow
or deny
are an ARRAY with any combination of
- IPv4 and IPv6 address ranges in CIDR notation
- hostname
- domain name (leading dot)
- your own CODE reference, which will be called with the IP address,
-
the hostname, the session, and the rewritten URI.
Return of list()
The list() method returns a HASH of HASHes, where the primary keys are the directory entries, each refering to a HASH with details. It is designed to ease the connection to template systems.
The details contain the lstat
information plus some additional helpers. The lstat call provides the fields dev
, ino
, mode
, nlink
, uid
, gid
, rdev
, size
, atime
, mtime
, ctime
, blksize
, blocks
-as far as supported by your OS. The entry's name
and path
are added.
The kind
field contains the string DIRECTORY
, FILE
, SYMLINK
, or OTHER
. Besides, you get either an is_directory
, is_file
, is_symlink
, or is_other
field set to true. Equivalent are:
if($entry->{kind} eq 'DIRECTORY')
if($entry->{is_directory})
It depends on the kind of entry which of the following fields are added additionally. Symlinks will get symlink_dest
, symlink_dest_exists
. Files hace the size_nice
, which is the size in pleasant humanly readable format.
Files and directories have the mtime_nice
(in localtime). The user
and group
which are textual representations of the numeric uid and gid are added. The flags
represents the UNIX standard permission-bit display, as produced by the "ls -l" command.
SEE ALSO
This module is part of Any-Daemon-HTTP distribution version 0.23, built on November 28, 2013. Website: http://perl.overmeer.net/any-daemon/
LICENSE
Copyrights 2013 by [Mark Overmeer]. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html