Any-Daemon-HTTP
view release on metacpan or search on metacpan
- move to Log::Report 1.00
- use IO::Socket::IP, to support IPv6
Fixes:
- no warning when request does not have Host
- show destination and owner of symlinks
- vhost not finding directory.
rt.cpan.org#91672 [Kenney Westerhof]
Improvements:
- ::Directory make charset configurable.
- minor cleanups after demo at Perl Mongers A'dam meeting
- now multiple ports possible
- deprecate ::HTTP::new(host) and ::new(socket) for new option
new(listen).
- add ::HTTP::run(max_conn_per_child)
- extracted ::HTTP::Source as base from ::HTTP::Directory
- add ::HTTP::Proxy
- ::Directory and ::Proxy objects share the "sources" path
mapping.
lib/Any/Daemon/HTTP/Directory.pm view on Meta::CPAN
$trans = _filename_trans $path, $loc;
-d $loc
or error __x"directory location {loc} for {path} does not exist"
, loc => $loc, path => $path;
}
$self->{ADHD_loc} = $loc;
$self->{ADHD_fn} = $trans;
$self->{ADHD_dirlist} = $args->{directory_list} || 0;
$self->{ADHD_charset} = $args->{charset} || 'utf-8';
my $if = $args->{index_file};
my @if = ref $if eq 'ARRAY' ? @$if
: defined $if ? $if
: qw/index.html index.htm/;
$self->{ADHD_indexfns} = \@if;
$self;
}
#-----------------
sub location() {shift->{ADHD_location}}
sub charset() {shift->{ADHD_charset}}
#-----------------
#-----------------------
sub filename($) { $_[0]->{ADHD_fn}->($_[1]) }
sub _filename_trans($$)
{ my ($path, $loc) = @_;
return $loc if ref $loc eq 'CODE';
lib/Any/Daemon/HTTP/Directory.pm view on Meta::CPAN
my $has_mtime = $req->if_modified_since;
return HTTP::Response->new(HTTP_NOT_MODIFIED, 'unchanged')
if defined $has_mtime && $has_mtime >= $mtime;
my $head = HTTP::Headers->new;
my $ct;
if(my $mime = $mimetypes->mimeTypeOf($fn))
{ $ct = $mime->type;
$ct .= '; charset='.$self->charset if $mime->isAscii;
}
else
{ $ct = 'binary/octet-stream';
}
$head->content_type($ct);
$head->last_modified($mtime);
$head->header(ETag => $etag);
local $/;
lib/Any/Daemon/HTTP/Directory.pm view on Meta::CPAN
<body>
<h1>Directory $dir</h1>
<table>
@rows
</table>
<p><i>Generated $now</i></p>
</body></html>
__PAGE
HTTP::Response->new(HTTP_OK, undef
, ['Content-Type' => 'text/html; charset='.$self->charset]
, $content
);
}
my %filetype =
( &S_IFSOCK => 's', &S_IFLNK => 'l', &S_IFREG => '-', &S_IFBLK => 'b'
, &S_IFDIR => 'd', &S_IFCHR => 'c', &S_IFIFO => 'p');
my @flags = ('---', '--x', '-w-', '-wx', 'r--', 'r-x', 'rw-', 'rwx');
lib/Any/Daemon/HTTP/Directory.pod view on Meta::CPAN
=head2 Constructors
Extends L<"Constructors" in Any::Daemon::HTTP::Source|Any::Daemon::HTTP::Source/"Constructors">.
=over 4
=item Any::Daemon::HTTP::Directory-E<gt>B<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 '/'
=over 2
=item allow => CIDR|HOSTNAME|DOMAIN|CODE|ARRAY
=item charset => STRING
The character-set which is used all text-files on the system, used in
response headers of text-files.
=item deny => CIDR|HOSTNAME|DOMAIN|CODE|ARRAY
=item directory_list => BOOLEAN
Enables the display of a directory, when it does not contain one of the
C<index_file> prepared defaults.
lib/Any/Daemon/HTTP/Directory.pod view on Meta::CPAN
=back
=back
=head2 Attributes
Extends L<"Attributes" in Any::Daemon::HTTP::Source|Any::Daemon::HTTP::Source/"Attributes">.
=over 4
=item $obj-E<gt>B<charset>()
=item $obj-E<gt>B<location>()
=item $obj-E<gt>B<name>()
Inherited, see L<Any::Daemon::HTTP::Source/"Attributes">
=item $obj-E<gt>B<path>()
Inherited, see L<Any::Daemon::HTTP::Source/"Attributes">
lib/Any/Daemon/HTTP/UserDirs.pod view on Meta::CPAN
=over 4
=item Any::Daemon::HTTP::UserDirs-E<gt>B<new>(%options|\%options)
The user-dir rewrite routine has by default Apache-like behavior.
-Option --Defined in --Default
allow Any::Daemon::HTTP::Source <undef>
allow_users undef
charset Any::Daemon::HTTP::Directory utf-8
deny Any::Daemon::HTTP::Source <undef>
deny_users []
directory_list Any::Daemon::HTTP::Directory <false>
index_file Any::Daemon::HTTP::Directory ['index.html', 'index.htm']
location Any::Daemon::HTTP::Directory CODE
name Any::Daemon::HTTP::Source path
path Any::Daemon::HTTP::Source <ignored>
user_subdirs 'public_html'
=over 2
=item allow => CIDR|HOSTNAME|DOMAIN|CODE|ARRAY
=item allow_users => ARRAY
Lists the user homes which are available. Cannot be used together with
C<deny_users>. By default, all user homes are permitted, even those
of system usernames like C<ftp> and C<cups>.
Only used with the default user-dir rewrite rule.
=item charset => STRING
=item deny => CIDR|HOSTNAME|DOMAIN|CODE|ARRAY
=item deny_users => ARRAY
Only used with the default user-dir rewrite rule.
=item directory_list => BOOLEAN
=item index_file => STRING|ARRAY
lib/Any/Daemon/HTTP/UserDirs.pod view on Meta::CPAN
=back
=back
=head2 Attributes
Extends L<"Attributes" in Any::Daemon::HTTP::Directory|Any::Daemon::HTTP::Directory/"Attributes">.
=over 4
=item $obj-E<gt>B<charset>()
Inherited, see L<Any::Daemon::HTTP::Directory/"Attributes">
=item $obj-E<gt>B<location>()
Inherited, see L<Any::Daemon::HTTP::Directory/"Attributes">
=item $obj-E<gt>B<name>()
Inherited, see L<Any::Daemon::HTTP::Source/"Attributes">
( run in 0.511 second using v1.01-cache-2.11-cpan-4d50c553e7e )