File: utf8_req.t

package info (click to toggle)
libplack-perl 0.9989-1%2Bdeb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,556 kB
  • sloc: perl: 6,890; python: 6; makefile: 2
file content (23 lines) | stat: -rw-r--r-- 553 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use Test::More;
use Encode;
use HTTP::Request;
use HTTP::Message::PSGI;

my @paths = (
    'П', '%D0%9F',
    decode_utf8('П'), '%D0%9F',
    'À', '%C3%80',
    decode_utf8('À'), '%C3%80',
);

while (my($raw, $encoded) = splice @paths, 0, 2) {
    my $req = HTTP::Request->new(GET => "http://localhost/" . $raw);
    my $env = $req->to_psgi;
    is $env->{REQUEST_URI}, "/$encoded";
    is $env->{PATH_INFO}, URI::Escape::uri_unescape("/$encoded");
    ok !utf8::is_utf8 $env->{PATH_INFO};
    ok !utf8::is_utf8 $env->{HTTP_HOST};
}

done_testing;