Home | History | Annotate | Download | only in tests
      1 #!/usr/bin/env perl
      2 #***************************************************************************
      3 #                                  _   _ ____  _
      4 #  Project                     ___| | | |  _ \| |
      5 #                             / __| | | | |_) | |
      6 #                            | (__| |_| |  _ <| |___
      7 #                             \___|\___/|_| \_\_____|
      8 #
      9 # Copyright (C) 2016, Daniel Stenberg, <daniel (at] haxx.se>, et al.
     10 #
     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.
     14 #
     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.
     18 #
     19 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
     20 # KIND, either express or implied.
     21 #
     22 #***************************************************************************
     23 
     24 # This script invokes nghttpx properly to have it serve HTTP/2 for us.
     25 # nghttpx runs as a proxy in front of our "actual" HTTP/1 server.
     26 
     27 my $pidfile = "log/nghttpx.pid";
     28 my $logfile = "log/http2.log";
     29 my $nghttpx = "nghttpx";
     30 my $listenport = 9015;
     31 
     32 #***************************************************************************
     33 # Process command line options
     34 #
     35 while(@ARGV) {
     36     if($ARGV[0] eq '--verbose') {
     37         $verbose = 1;
     38     }
     39     elsif($ARGV[0] eq '--pidfile') {
     40         if($ARGV[1]) {
     41             $pidfile = $ARGV[1];
     42             shift @ARGV;
     43         }
     44     }
     45     elsif($ARGV[0] eq '--nghttpx') {
     46         if($ARGV[1]) {
     47             $nghttpx = $ARGV[1];
     48             shift @ARGV;
     49         }
     50     }
     51     elsif($ARGV[0] eq '--port') {
     52         if($ARGV[1]) {
     53             $listenport = $ARGV[1];
     54             shift @ARGV;
     55         }
     56     }
     57     elsif($ARGV[0] eq '--logfile') {
     58         if($ARGV[1]) {
     59             $logfile = $ARGV[1];
     60             shift @ARGV;
     61         }
     62     }
     63     else {
     64         print STDERR "\nWarning: http2-server.pl unknown parameter: $ARGV[0]\n";
     65     }
     66     shift @ARGV;
     67 }
     68 
     69 my $cmdline="$nghttpx --backend=127.0.0.1,8990 ".
     70     "--frontend=\"*,$listenport;no-tls\" ".
     71     "--log-level=INFO ".
     72     "--pid-file=$pidfile ".
     73     "--errorlog-file=$logfile";
     74 print "RUN: $cmdline\n" if($verbose);
     75 system("$cmdline 2>/dev/null");
     76