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 https://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 $unix_socket; # location to place a listening Unix socket
40 my $ipvnum = 4; # default IP version of http server
41 my $idnum = 1; # default http server instance number
42 my $proto = 'http'; # protocol the http server speaks
43 my $pidfile; # http server pid file
44 my $logfile; # http server log file
45 my $connect; # IP to connect to on CONNECT
51 my $logdir = $path .'/log';
54 if($ARGV[0] eq '--pidfile') {
60 elsif($ARGV[0] eq '--logfile') {
66 elsif($ARGV[0] eq '--srcdir') {
72 elsif($ARGV[0] eq '--ipv4') {
75 elsif($ARGV[0] eq '--ipv6') {
78 elsif($ARGV[0] eq '--unix-socket') {
81 $unix_socket = $ARGV[1];
85 elsif($ARGV[0] eq '--gopher') {
88 elsif($ARGV[0] eq '--port') {
89 if($ARGV[1] =~ /^(\d+)$/) {
94 elsif($ARGV[0] eq '--connect') {
100 elsif($ARGV[0] eq '--id') {
101 if($ARGV[1] =~ /^(\d+)$/) {
102 $idnum = $1 if($1 > 0);
106 elsif($ARGV[0] eq '--verbose') {
110 print STDERR "\nWarning: httpserver.pl unknown parameter: $ARGV[0]\n";
116 $srcdir = $ENV{'srcdir'} || '.';
119 $pidfile = "$path/". server_pidfilename($proto, $ipvnum, $idnum);
122 $logfile = server_logfilename($logdir, $proto, $ipvnum, $idnum);
125 $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" ";
126 $flags .= "--gopher " if($gopher);
127 $flags .= "--connect $connect " if($connect);
128 if($ipvnum eq 'unix') {
129 $flags .= "--unix-socket '$unix_socket' ";
131 $flags .= "--ipv$ipvnum --port $port ";
133 $flags .= "--srcdir \"$srcdir\"";
136 print STDERR "RUN: server/sws $flags\n";
139 exec("server/sws $flags");