1 package HTTP::Body::UrlEncoded;
8 our $DECODE = qr/%([0-9a-fA-F]{2})/;
12 for my $num ( 0 .. 255 ) {
13 my $h = sprintf "%02X", $num;
14 $hex_chr{ lc $h } = $hex_chr{ uc $h } = chr $num;
19 HTTP::Body::UrlEncoded - HTTP Body UrlEncoded Parser
23 use HTTP::Body::UrlEncoded;
27 HTTP Body UrlEncoded Parser.
40 return unless $self->length == $self->content_length;
42 # Store a copy of the raw request that the body() method can return
44 $self->body(IO::Handle::Util::io_from_any($self->{buffer}));
46 # I tested parsing this using APR::Request, but perl is faster
50 # Note: s/// appears faster than tr///
51 $self->{buffer} =~ s/\+/ /g;
53 for my $pair ( split( /[&;](?:\s+)?/, $self->{buffer} ) ) {
55 my ( $name, $value ) = split( /=/, $pair , 2 );
57 next unless defined $name;
58 next unless defined $value;
60 $name =~ s/$DECODE/$hex_chr{$1}/gs;
61 $value =~ s/$DECODE/$hex_chr{$1}/gs;
63 $self->param( $name, $value );
67 $self->{state} = 'done';
74 Christian Hansen, C<ch@ngmedia.com>
76 Andy Grundman, C<andy@hybridized.org>
80 This library is free software . You can redistribute it and/or modify
81 it under the same terms as perl itself.