The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Any::Daemon::HTTP::Directory - describe a server directory

INHERITANCE

 Any::Daemon::HTTP::Directory
   is an Any::Daemon::HTTP::Source

 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 (virtual) directories, with different access rights.

Extends "DESCRIPTION" in Any::Daemon::HTTP::Source.

METHODS

Extends "METHODS" in Any::Daemon::HTTP::Source.

Constructors

Extends "Constructors" in Any::Daemon::HTTP::Source.

Any::Daemon::HTTP::Directory->new(%options|\%options)
 -Option        --Defined in               --Default
  allow           Any::Daemon::HTTP::Source  <undef>
  charset                                    utf-8
  deny            Any::Daemon::HTTP::Source  <undef>
  directory_list                             <false>
  index_file                                 ['index.html', 'index.htm']
  location                                   <required>
  name            Any::Daemon::HTTP::Source  path
  path            Any::Daemon::HTTP::Source  '/'
allow => CIDR|HOSTNAME|DOMAIN|CODE|ARRAY
charset => STRING

The character-set which is used all text-files on the system, used in response headers of text-files.

deny => CIDR|HOSTNAME|DOMAIN|CODE|ARRAY
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.

name => STRING
path => PATH

Attributes

Extends "Attributes" in Any::Daemon::HTTP::Source.

$obj->charset()
$obj->location()
$obj->name()

Inherited, see "Attributes" in Any::Daemon::HTTP::Source

$obj->path()

Inherited, see "Attributes" in Any::Daemon::HTTP::Source

Permissions

Extends "Permissions" in Any::Daemon::HTTP::Source.

$obj->allow($session, $request, $uri)

Inherited, see "Permissions" in Any::Daemon::HTTP::Source

$obj->collect($vhost, $session, $request, $uri)

Inherited, see "Permissions" in Any::Daemon::HTTP::Source

Actions

Extends "Actions" in Any::Daemon::HTTP::Source.

$obj->filename($path)

Convert a URI $path into a directory path. Return undef if not possible.

$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).

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

Extends "DETAILS" in Any::Daemon::HTTP::Source.

Resource restrictions

Extends "Resource restrictions" in Any::Daemon::HTTP::Source.

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.28, built on March 20, 2019. Website: http://perl.overmeer.net/any-daemon/

LICENSE

Copyrights 2013-2019 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://dev.perl.org/licenses/