2 #***************************************************************************
4 # Project ___| | | | _ \| |
6 # | (__| |_| | _ <| |___
7 # \___|\___/|_| \_\_____|
9 # Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
11 # This software is licensed as described in the file COPYING, which
12 # you should have received as part of this distribution. The terms
13 # are also available at http://curl.haxx.se/docs/copyright.html.
15 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
16 # copies of the Software, and permit persons to whom the Software is
17 # furnished to do so, under the terms of the COPYING file.
19 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 # KIND, either express or implied.
22 #***************************************************************************
25 push(@INC, $ENV{'srcdir'}) if(defined $ENV{'srcdir'});
37 my $verbose = 0; # set to 1 for debugging
38 my $port = 8990; # just a default
39 my $ipvnum = 4; # default IP version of http server
40 my $idnum = 1; # dafault http server instance number
41 my $proto = 'http'; # protocol the http server speaks
42 my $pidfile; # http server pid file
43 my $logfile; # http server log file
44 my $connect; # IP to connect to on CONNECT
50 my $logdir = $path .'/log';
53 if($ARGV[0] eq '--pidfile') {
59 elsif($ARGV[0] eq '--logfile') {
65 elsif($ARGV[0] eq '--srcdir') {
71 elsif($ARGV[0] eq '--ipv4') {
74 elsif($ARGV[0] eq '--ipv6') {
77 elsif($ARGV[0] eq '--gopher') {
80 elsif($ARGV[0] eq '--port') {
81 if($ARGV[1] =~ /^(\d+)$/) {
86 elsif($ARGV[0] eq '--connect') {
92 elsif($ARGV[0] eq '--id') {
93 if($ARGV[1] =~ /^(\d+)$/) {
94 $idnum = $1 if($1 > 0);
98 elsif($ARGV[0] eq '--verbose') {
102 print STDERR "\nWarning: httpserver.pl unknown parameter: $ARGV[0]\n";
108 $srcdir = $ENV{'srcdir'} || '.';
111 $pidfile = "$path/". server_pidfilename($proto, $ipvnum, $idnum);
114 $logfile = server_logfilename($logdir, $proto, $ipvnum, $idnum);
117 $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" ";
118 $flags .= "--gopher " if($gopher);
119 $flags .= "--connect $connect " if($connect);
120 $flags .= "--ipv$ipvnum --port $port --srcdir \"$srcdir\"";
123 print STDERR "RUN: server/sws $flags\n";
126 exec("server/sws $flags");