Subject: | svnweb-server doesn't run out of the box |
svnweb-server has a couple of bugs:
1) %options doesn't have a sane default value
2) $self->host() doesn't get set correctly
3) default cgi_class CGI::Fast doesn't work well with svnweb-server
Attached patch fixes 1) and 2). I manually added "cgi_class: CGI" to
config.yaml and worked around it, but there should be a way to avoid
this in svnweb-server.
Subject: | svn-web.patch |
=== bin/svnweb-server
==================================================================
--- bin/svnweb-server (revision 24586)
+++ bin/svnweb-server (local)
@@ -8,6 +8,7 @@
use base qw(HTTP::Server::Simple::CGI);
use Getopt::Long;
+use Sys::Hostname;
=head1 NAME
@@ -52,9 +53,9 @@
=cut
-my %options = ('root=s' => '.',
- 'port=i' => '8080',
- 'net-server=s' => undef);
+my %options = ('root' => '.',
+ 'port' => '8080',
+ 'net-server' => undef);
GetOptions('root=s' => \$options{root},
'port=i' => \$options{port},
@@ -72,12 +73,19 @@
print <FILE>;
close FILE;
} else {
- $ENV{SCRIPT_NAME} = 'http://' . $self->host() . ':' . $self->port();
+ $ENV{SCRIPT_NAME} = 'http://' . $self->get_host() . ':' . $self->port();
print "HTTP/1.1 200 OK\n";
SVN::Web::run_cgi();
}
}
+sub get_host {
+ my $self = shift;
+ my $host = $ENV{HTTP_HOST} || Sys::Hostname::hostname() || 'localhost';
+ $host =~ s/:(\d+)$//; # remove port from Host: header
+ $host;
+}
+
use CGI::Carp qw(fatalsToBrowser);
my $server = __PACKAGE__->new($options{port});