3 # This file is part of the dgit test suite.
5 # Copyright (C)2004-2015 Best Practical Solutions, LLC
6 # Copyright (C)2019 Ian Jackson
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
21 # < tests/tmp/$test/some-file \
22 # ftpmasterapi-static-server \
28 $SIG{ALRM} = sub { print STDERR "y\n"; };
35 use Socket qw(AF_INET SOCK_STREAM);
36 use Socket qw(AF_INET SOCK_STREAM unpack_sockaddr_in);
40 use base qw(HTTP::Server::Simple::CGI);
41 use HTTP::Server::Simple::Static;
43 my $webroot = '/var/www';
46 my ( $self, $cgi ) = @_;
48 if ( !$self->serve_static( $cgi, $webroot ) ) {
49 print "HTTP/1.0 404 Not found\r\n";
51 $cgi->start_html('Not found'),
52 $cgi->h1('Not found'),
57 sub port () { return 0; }
59 sub xsetup_listener ()
62 print STDERR "foo!", $self->stdio_handle(), "\n";
63 my $sock = new IO::Handle;
64 socket $sock, AF_INET, SOCK_STREAM, 0 or die $!;
65 #$self->stdio_handle($sock);
68 sub after_setup_listener () {
69 my $x = getsockname HTTP::Server::Simple::HTTPDaemon or die $!;
70 print STDERR Dumper(unpack_sockaddr_in $x);
75 my $server = MyServer->new();