|
| 1 | +#!/usr/bin/env perl |
| 2 | +# This Source Code Form is subject to the terms of the Mozilla Public |
| 3 | +# License, v. 2.0. If a copy of the MPL was not distributed with this |
| 4 | +# file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 5 | +# |
| 6 | +# This Source Code Form is "Incompatible With Secondary Licenses", as |
| 7 | +# defined by the Mozilla Public License, v. 2.0. |
| 8 | + |
| 9 | +use 5.10.1; |
| 10 | +use strict; |
| 11 | +use warnings; |
| 12 | + |
| 13 | +use lib qw(. lib local/lib/perl5); |
| 14 | + |
| 15 | +use Bugzilla; |
| 16 | +use Bugzilla::Util qw(html_quote); |
| 17 | + |
| 18 | +my $cgi = Bugzilla->cgi; |
| 19 | + |
| 20 | +print $cgi->header(-type => 'text/html', -charset => 'utf-8'); |
| 21 | + |
| 22 | +print <<'HTML'; |
| 23 | +<!DOCTYPE html> |
| 24 | +<html> |
| 25 | +<head> |
| 26 | +<title>Request Headers</title> |
| 27 | +<style> |
| 28 | + body { font-family: monospace; padding: 20px; } |
| 29 | + table { border-collapse: collapse; width: 100%; } |
| 30 | + th, td { border: 1px solid #ccc; padding: 8px 12px; text-align: left; vertical-align: top; white-space: nowrap;} |
| 31 | + th { background: #eee; font-weight: bold; } |
| 32 | + tr:nth-child(even) { background: #f9f9f9; } |
| 33 | +</style> |
| 34 | +</head> |
| 35 | +<body> |
| 36 | +<h1>Request Headers</h1> |
| 37 | +<table> |
| 38 | +<thead><tr><th>Header</th><th>Value</th></tr></thead> |
| 39 | +<tbody> |
| 40 | +HTML |
| 41 | + |
| 42 | +for my $key (sort $cgi->http()) { |
| 43 | + my $value = $cgi->http($key) // ''; |
| 44 | + (my $name = $key) =~ s/^HTTP_//; |
| 45 | + $name = join('-', map { ucfirst(lc($_)) } split(/_/, $name)); |
| 46 | + $name = html_quote($name); |
| 47 | + $value = html_quote($value); |
| 48 | + print "<tr><td>$name</td><td>$value</td></tr>\n"; |
| 49 | +} |
| 50 | + |
| 51 | +print <<'HTML'; |
| 52 | +</tbody> |
| 53 | +</table> |
| 54 | +</body> |
| 55 | +</html> |
| 56 | +HTML |
0 commit comments