问题
I'm using HTTP::Server::Simple::CGI for a light-weight HTTP server. That gives me a CGI object in a callback function when a HTTP request is accepted.
How can I access the incoming HTTP headers, especially non-standard headers? The environment variables are only the standard ones.
cgi->param
gives me only the form parameters.
Thanks! chris
回答1:
It says in the documentation:
You can, if you really want, define parse_headers() and parse them raw yourself.
回答2:
Define the headers
method to receive the headers.
sub headers
{
my $self = shift;
my $headers = shift;
my @h = @{$headers};
while (0 + @h)
{
my $k = shift @h;
my $v = shift @h;
print STDERR "header >> $k: $v\n";
}
}
来源:https://stackoverflow.com/questions/3093160/how-do-i-access-http-request-headers-in-httpserversimplecgi