use warnings; use strict; use Data::Dumper; use Test::More('tests', 19); use HTTP::Status; BEGIN { use_ok('POE::Filter::SimpleHTTP'); use_ok('POE::Filter::SimpleHTTP::Regex'); use_ok('POE::Filter::SimpleHTTP::Error'); } $POE::Filter::SimpleHTTP::DEBUG = 0; my $request_data = <<'REQUEST'; GET / HTTP/1.0 User-Agent: Wget/1.11.4 Accept: */* Host: localhost:64000 Connection: Keep-Alive REQUEST my $response_data = <<'RESPONSE'; HTTP/1.0 200 OK Cache-Control: private, max-age=0 Date: Tue, 21 Apr 2009 16:10:03 GMT Expires: -1 Content-Type: text/html; charset=ISO-8859-1 Set-Cookie: PREF=ID=7adf5b9e3e51d251:TM=1240330203:LM=1240330203:S=61k21igTTXkLcR5z; expires=Thu, 21-Apr-2011 16:10:03 GMT; path=/; domain=.google.com Server: gws Google
Web Images Maps News Video Gmail more »
iGoogle | Sign in

Google

 
  Advanced Search
  Preferences
  Language Tools


Advertising Programs - Business Solutions - About Google

©2009 - Privacy

RESPONSE my $response_chunked = <<'CHUNKED'; HTTP/1.1 200 OK Cache-Control: private, max-age=0 Date: Tue, 21 Apr 2009 20:27:45 GMT Expires: -1 Content-Type: text/html; charset=ISO-8859-1 Set-Cookie: PREF=ID=25452f5dd13e4bed:TM=1240345665:LM=1240345665:S=dpSsSFgwWhK_PaLX; expires=Thu, 21-Apr-2011 20:27:45 GMT; path=/; domain=.google.com Server: gws Transfer-Encoding: chunked fef Google
Web Images Maps News Video Gmail more »
iGoogle | Sign in

Google

 
  Advanced Search
  Preferences
  Language Tools


Advertising Programs - Business Solutions - About Google

©2009 - Privacy

0 CHUNKED my $response_chunked_compressed = <<'COMPRESSED'; HTTP/1.1 200 OK Cache-Control: max-age=172800 Date: Tue, 21 Apr 2009 23:25:48 GMT Transfer-Encoding: gzip,chunked Content-Md5: BpMcfPwGUXC7g/FpbRkO/A== Content-Type: text/plain Etag: "1pe1kjm:q7kclme8" Expires: Thu, 23 Apr 2009 23:25:48 GMT Last-Modified: Thu, 27 Dec 2001 17:40:27 GMT Server: Jigsaw/2.3.0-beta1 B ‹ 56 íÆ¡ 00¿+¸d!óÎ狩V5_Eßé“"""""""""""""""""""""""""""""""""""ò+ kÔÖ H 0 COMPRESSED my $response_chunked_deflated = <<'DEFLATED'; HTTP/1.1 200 OK Cache-Control: max-age=172800 Date: Wed, 22 Apr 2009 00:50:41 GMT Transfer-Encoding: deflate,chunked Content-Md5: BpMcfPwGUXC7g/FpbRkO/A== Content-Type: text/plain Etag: "1pe1kjm:q7kclme8" Expires: Fri, 24 Apr 2009 00:50:41 GMT Last-Modified: Thu, 27 Dec 2001 17:40:27 GMT Server: Jigsaw/2.3.0-beta1 58 xœíÆ¡ 00¿+¸d!óÎ狩V5_Eßé“"""""""""""""""""""""""""""""""""""ò+ ] x 0 DEFLATED my $filter = POE::Filter::SimpleHTTP->new(); isa_ok($filter, 'POE::Filter'); isa_ok($filter, 'Moose::Object'); isa_ok($filter, 'POE::Filter::SimpleHTTP'); my $clone = $filter->clone(); isa_ok($clone, 'POE::Filter'); isa_ok($clone, 'Moose::Object'); isa_ok($clone, 'POE::Filter::SimpleHTTP'); $request_data =~ s/\n/\x0d\x0a/g; $filter->get_one_start($request_data); my $request = $filter->get_one()->[0]; #diag(Dumper($request)); isa_ok($request, 'HTTP::Request'); is($request->uri(), URI->new('/'), 'URI for the request'); #diag($request->content()); $response_data =~ s/\n/\x0d\x0a/g; $filter->get_one_start($response_data); my $response = $filter->get_one()->[0]; #diag(Dumper($response)); isa_ok($response, 'HTTP::Response'); is($response->code(), +RC_OK, 'Code for the response'); #diag($response->content()); $response_chunked =~ s/\n/\x0d\x0a/g; $filter->get_one_start($response_chunked); my $chunked = $filter->get_one()->[0]; #diag(Dumper($chunked)); isa_ok($chunked, 'HTTP::Response'); is($chunked->code(), +RC_OK, 'Code for chunked'); #diag($chunked->content()); $response_chunked_compressed =~ s/\n/\x0d\x0a/g; $filter->get_one_start($response_chunked_compressed); my $compressed = $filter->get_one()->[0]; #diag(Dumper($compressed)); isa_ok($compressed, 'HTTP::Response'); is($compressed->code(), +RC_OK, 'Code for compressed'); #diag($compressed->content()); $response_chunked_deflated =~ s/\n/\x0d\x0a/g; $filter->get_one_start($response_chunked_deflated); my $deflated = $filter->get_one()->[0]; #diag(Dumper($deflated)); isa_ok($deflated, 'HTTP::Response'); is($deflated->code(), +RC_OK, 'Code for deflated'); #diag($deflated->content());