|
Revision 18687, 0.9 kB
(checked in by tokuhirom, 5 years ago)
|
|
hmm... $req->uri->path returns different value between interface.
|
| Line | |
|---|
| 1 | use strict; |
|---|
| 2 | use warnings; |
|---|
| 3 | use t::Utils; |
|---|
| 4 | use Test::More; |
|---|
| 5 | |
|---|
| 6 | plan tests => 2*interfaces; |
|---|
| 7 | |
|---|
| 8 | use LWP::UserAgent; |
|---|
| 9 | use HTTP::Engine; |
|---|
| 10 | |
|---|
| 11 | daemonize_all sub { |
|---|
| 12 | my ($port, $interface) = @_; |
|---|
| 13 | |
|---|
| 14 | my $ua = LWP::UserAgent->new(timeout => 10); |
|---|
| 15 | $ua->proxy('http', "http://localhost:$port/"); |
|---|
| 16 | my $res = $ua->get("http://localhost:$port/?http=1"); |
|---|
| 17 | is $res->code, 200, $interface; |
|---|
| 18 | is $res->content, '/'; # which one is best? |
|---|
| 19 | } => <<'...'; |
|---|
| 20 | sub { |
|---|
| 21 | my $port = shift; |
|---|
| 22 | return ( |
|---|
| 23 | poe_kernel_run => 1, |
|---|
| 24 | interface => { |
|---|
| 25 | args => { |
|---|
| 26 | port => $port, |
|---|
| 27 | }, |
|---|
| 28 | request_handler => sub { |
|---|
| 29 | my $req = shift; |
|---|
| 30 | HTTP::Engine::Response->new( |
|---|
| 31 | status => 200, |
|---|
| 32 | body => $req->uri->path, |
|---|
| 33 | ); |
|---|
| 34 | }, |
|---|
| 35 | }, |
|---|
| 36 | ); |
|---|
| 37 | } |
|---|
| 38 | ... |
|---|
| 39 | |
|---|