AnyEvent::HTTPD::Util - Utility functions for AnyEvent::HTTPD


AnyEvent-HTTPD documentation Contained in the AnyEvent-HTTPD distribution.

Index


Code Index:

NAME

Top

AnyEvent::HTTPD::Util - Utility functions for AnyEvent::HTTPD

SYNOPSIS

Top

DESCRIPTION

Top

The functions in this package are not public.

AUTHOR

Top

Robin Redeker, <elmex@ta-sa.org>

SEE ALSO

Top

COPYRIGHT & LICENSE

Top


AnyEvent-HTTPD documentation Contained in the AnyEvent-HTTPD distribution.
package AnyEvent::HTTPD::Util;
use common::sense;

require Exporter;
our @ISA = qw/Exporter/;

our @EXPORT = qw/parse_urlencoded url_unescape/;

sub url_unescape {
   my ($val) = @_;
   $val =~ s/\+/\040/g;
   $val =~ s/%([0-9a-fA-F][0-9a-fA-F])/chr (hex ($1))/eg;
   $val
}

sub parse_urlencoded {
   my ($cont) = @_;
   my (@pars) = split /[\&\;]/, $cont;
   $cont = {};

   for (@pars) {
      my ($name, $val) = split /=/, $_;
      $name = url_unescape ($name);
      $val  = url_unescape ($val);

      push @{$cont->{$name}}, [$val, ''];
   }
   $cont
}



1;