1 package HTTP::Body::UrlEncoded;
7 our $DECODE = qr/%([0-9a-fA-F]{2})/;
11 for my $num ( 0 .. 255 ) {
12 my $h = sprintf "%02X", $num;
13 $hex_chr{ lc $h } = $hex_chr{ uc $h } = chr $num;
18 HTTP::Body::UrlEncoded - HTTP Body UrlEncoded Parser
22 use HTTP::Body::UrlEncoded;
26 HTTP Body UrlEncoded Parser.
39 return unless $self->length == $self->content_length;
41 # I tested parsing this using APR::Request, but perl is faster
45 # Note: s/// appears faster than tr///
46 $self->{buffer} =~ s/\+/ /g;
48 for my $pair ( split( /&|;(?:\s+)?/, $self->{buffer} ) ) {
50 my ( $name, $value ) = split( /=/, $pair , 2 );
52 next unless defined $name;
53 next unless defined $value;
55 $name =~ s/$DECODE/$hex_chr{$1}/gs;
56 $value =~ s/$DECODE/$hex_chr{$1}/gs;
58 $self->param( $name, $value );
62 $self->{state} = 'done';
69 Christian Hansen, C<ch@ngmedia.com>
71 Andy Grundman, C<andy@hybridized.org>
75 This library is free software . You can redistribute it and/or modify
76 it under the same terms as perl itself.