/t/helper/child-httpd.pl

http://github.com/perlbal/Perlbal · Perl · 18 lines · 11 code · 5 blank · 2 comment · 1 complexity · 28459fb646704d3b8e34e8da5aa47d2e MD5 · raw file

  1. #!/usr/bin/perl
  2. use strict;
  3. my $req = <>;
  4. die "Bogus request" unless $req =~ /^GET (\/\S*) HTTP\/1\.\d/;
  5. $| = 1;
  6. my $uri = $1;
  7. while (<>) {
  8. last unless /\S/;
  9. }
  10. my $response = "You wanted [$uri] and I am pid=$$\n";
  11. #warn "Response from pid $$: [$response]\n";
  12. my $len = length $response;
  13. print "HTTP/1.0 200 OK\r\nContent-Length: $len\r\n\r\n$response";