/[suikacvs]/www/test/support/dump-request.cgi
Suika

Contents of /www/test/support/dump-request.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Sun Jan 22 02:34:21 2012 UTC (13 years, 3 months ago) by wakaba
Branch: MAIN
CVS Tags: HEAD
Current

1 #!/usr/bin/perl
2 use strict;
3
4 sub escape ($) {
5 my $s = shift;
6 $s =~ s/([^\x20-\x5B\x5D-\x7E])/sprintf '\x%02X', ord $1/ge;
7 return $s;
8 } # escape
9
10 print "Content-Type: text/plain; charset=us-ascii\n\n";
11
12 print "Request-Method: {", escape ($ENV{REQUEST_METHOD}), "}\n\n";
13
14 print "Request-URI: {", escape ($ENV{REQUEST_URI}), "}\n\n";
15
16 print "HTTP header fields:\n";
17 for (sort {$a cmp $b} ('CONTENT_TYPE', grep /^HTTP_/, keys %ENV)) {
18 print "{", escape ($_), "}: {", escape ($ENV{$_}), "}\n";
19 }
20 print "\n";
21
22 print "Request-body:\n";
23 if (defined $ENV{CONTENT_LENGTH}) {
24 my $size = $ENV{CONTENT_LENGTH};
25 $size = 10 * 1024 if $size > 10 * 1024;
26 read STDIN, my $bytes, $size;
27 $bytes = escape ($bytes);
28 $bytes =~ s/\\x0A/\\x0A\n/g;
29 print "[", $bytes, ($size == 10 * 1024 ? "..." : "}"), "\n";
30 }
31 print "\n";

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24