开发者

How do I access HTTP request headers in HTTP::Server::Simple::CGI?

开发者 https://www.devze.com 2023-01-04 13:39 出处:网络
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.

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 head开发者_JAVA技巧ers, especially non-standard headers? The environment variables are only the standard ones.

cgi->param gives me only the form parameters.

Thanks! chris


It says in the documentation:

You can, if you really want, define parse_headers() and parse them raw yourself.


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";
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消