File: 01_filter_resp.t

package info (click to toggle)
libpoe-filter-http-parser-perl 1.08-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 152 kB
  • sloc: perl: 212; makefile: 2
file content (43 lines) | stat: -rw-r--r-- 1,318 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use strict;
use warnings;
use Test::More tests => 25;
use_ok('POE::Filter::HTTP::Parser');

my $filter = POE::Filter::HTTP::Parser->new( type => 'response' );
my $clone = $filter->clone();

my @data = (
"HTTP/1.1 200 OK\x0D\x0A",
"Connection: close\x0D\x0A",
"Date: Wed, 21 Jan 2009 11:24:23 GMT\x0D\x0A",
"Server: Apache\x0D\x0A",
"Content-Length: 204\x0D\x0A",
"Content-Type: text/html; charset=UTF-8\x0D\x0A",
"Content-Type: text/html; charset=iso-8859-1\x0D\x0A",
"Client-Date: Wed, 21 Jan 2009 11:24:23 GMT\x0D\x0A",
"Client-Peer: 62.234.135.115:80\x0D\x0A",
"Client-Response-Num: 1\x0D\x0A",
"\x0D\x0A",
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">\n",
"<html>\n",
"    <head>\n",
"        <title>GumbyNet - ORG - UK</title>\n",
"    </head>\n",
"    <body>\n",
"<center><img src=\"images/binnetbut.jpg\"></center>\n",
"    </body>\n",
"</html>\n",
);

foreach my $test ( $filter, $clone ) {
   isa_ok( $test, 'POE::Filter::HTTP::Parser' );
   isa_ok( $test, 'POE::Filter' );

   my $events = $filter->get( [ join( '', @data, @data, @data )  ] );
   ok( scalar @$events == 3, 'Got three responses' );
   foreach my $resp ( @$events ) {
     isa_ok( $resp, 'HTTP::Response' );
     is( $resp->code, '200', 'Response code okay' );
     like( $resp->content, qr/binnetbut.jpg/, 'Content was okay' );
   }
}