404.pl 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env perl
  2. my $request_uri = $ENV{'REQUEST_URI'};
  3. if ($request_uri =~ m/^\/dynamic\/200\// ) {
  4. print "Status: 200\n",
  5. "Content-Type: text/plain\n",
  6. "\n",
  7. "found here\n";
  8. }
  9. elsif ($request_uri =~ m|^/dynamic/302/| ) {
  10. print "Status: 302\n",
  11. "Location: http://www.example.org/\n",
  12. "\n";
  13. }
  14. elsif ($request_uri =~ m/^\/dynamic\/404\// ) {
  15. print "Status: 404\n",
  16. "Content-Type: text/plain\n",
  17. "\n",
  18. "Not found here\n";
  19. }
  20. elsif ($request_uri =~ m/^\/send404\.pl/ ) {
  21. print "Status: 404\n",
  22. "Content-Type: text/plain\n",
  23. "\n",
  24. "Not found here (send404)\n";
  25. }
  26. elsif ($request_uri =~ m/^\/dynamic\/nostatus\// ) {
  27. print ("found here\n");
  28. }
  29. elsif ($request_uri =~ m/^\/dynamic\/redirect_status\// ) {
  30. print "Status: $ENV{'REDIRECT_STATUS'}\n",
  31. "Content-Type: text/plain\n",
  32. "\n",
  33. "REDIRECT_STATUS\n";
  34. }
  35. elsif ($ENV{PATH_INFO} eq "/internal-redir" ) {
  36. # (not actually 404 error, but use separate script from cgi.pl for testing)
  37. print "Status: 200\r\n\r\n";
  38. }
  39. else {
  40. print "Status: 500\n",
  41. "Content-Type: text/plain\n",
  42. "\n",
  43. "huh\n";
  44. };