Apache2-POST200

 view release on metacpan or  search on metacpan

lib/Apache2/POST200.pm  view on Meta::CPAN

	foreach my $line (split /\n/, $l->[1]) {
	  $r->headers_out->add(split /: /, $line, 2)
	    if( length $line );
	}
      } elsif( $i==2 ) {	# err_headers_out
	$r->err_headers_out->clear;
	foreach my $line (split /\n/, $l->[1]) {
	  $r->err_headers_out->add(split /: /, $line, 2)
	    if( length $line );
	}
      } elsif( $i==3 ) {	# content-type
	$r->content_type($l->[1]);
      } else {			# data
	$r->print( $l->[1] );
      }
    } else {
      $r->warn( "Read incomplete data from database" );
    }
    $i++;
  }

t/001mp-handler.t  view on Meta::CPAN

         "X-My-Header: hallo opi\n", n 'checking my header';

ok t_cmp $dbh->selectall_arrayref
           ('SELECT data FROM p200 WHERE session=?', {},
	    substr( $loc, -32 ).':00000002')->[0]->[0],
         "X-My-Error: error\n", n 'checking my error header';

ok t_cmp $dbh->selectall_arrayref
           ('SELECT data FROM p200 WHERE session=?', {},
	    substr( $loc, -32 ).':00000003')->[0]->[0],
         "text/slain", n 'checking content-type';

ok t_cmp $dbh->selectall_arrayref
           ('SELECT data FROM p200 WHERE session=?', {},
	    substr( $loc, -32 ).':00000004')->[0]->[0],
         'POST:', n 'POST result in DB';

t_debug "follow redirect: GET $loc";
$resp=GET $loc;
ok t_cmp $resp->content, 'POST:', n 'POST content=POST';
ok t_cmp $resp->header('X-My-Header'), 'hallo opi', n 'response header';
ok t_cmp $resp->header('X-My-Error'), 'error', n 'response error header';
ok t_cmp $resp->content_type, 'text/slain', n 'response content-type';

t_debug "GET $loc;nocheck";
$resp=GET $loc.';nocheck';
ok t_cmp $resp->code, 200, n 'POST200IpCheck Off: code 200';
ok t_cmp $resp->content, 'POST:', n 'POST200IpCheck Off: content';

t_client_log_error_is_expected;
t_debug "GET $loc;check";
$resp=GET $loc.';check';
ok t_cmp $resp->code, 404, n 'POST200IpCheck On: code 404';

t/002cgi.t  view on Meta::CPAN

ok t_cmp $resp->code, 302, n 'POST => 302';
ok t_cmp $loc, qr!\Q$hostport\E/cgi/method\?-redirect-[A-Za-z0-9@=-]{32}$!, n 'Location';
ok t_cmp $dbh->selectall_arrayref
           ('SELECT data FROM p200 WHERE session=?', {},
	    substr( $loc, -32 ).':00000002')->[0]->[0],
         "X-My-Header: hallo opi\n", n 'checking my header';

ok t_cmp $dbh->selectall_arrayref
           ('SELECT data FROM p200 WHERE session=?', {},
	    substr( $loc, -32 ).':00000003')->[0]->[0],
         "text/slain", n 'checking content-type';

ok t_cmp $dbh->selectall_arrayref
           ('SELECT data FROM p200 WHERE session=?', {},
	    substr( $loc, -32 ).':00000004')->[0]->[0],
         'POST:', n 'POST result in DB';

$resp=GET $loc;
ok t_cmp $resp->content, 'POST:', n 'POST content=POST';
ok t_cmp $resp->header('X-My-Header'), 'hallo opi', n 'response header';
ok t_cmp $resp->content_type, 'text/slain', n 'response content-type';

$resp=POST $loc;
ok t_cmp $resp->code, 302, n 'POST => 302';
ok t_cmp $resp->header('Location'), qr#^(?!\Q$loc\E)#, n 'Location ne '.$loc;
ok t_cmp $resp->header('Location'), qr!\Q$hostport\E/cgi/method\?-redirect-[A-Za-z0-9@=-]{32}$!, n 'Location';
ok t_cmp $dbh->selectall_arrayref
           ('SELECT data FROM p200 WHERE session=?', {},
	    substr( $resp->header('Location'), -32 ).':00000004')->[0]->[0],
         'POST:', n 'POST result in DB';

t/004proxy.t  view on Meta::CPAN


my $header=$dbh->selectall_arrayref
  ('SELECT data FROM p200 WHERE session=?', {},
   substr( $loc, -32 ).':00000001')->[0]->[0];
ok t_cmp $header, qr/^X-My-Header: hallo opi\r?$/m, n 'checking my header';
ok t_cmp $header, qr/^X-My-Error: error\r?$/m, n 'checking my error header';

ok t_cmp $dbh->selectall_arrayref
           ('SELECT data FROM p200 WHERE session=?', {},
	    substr( $loc, -32 ).':00000003')->[0]->[0],
         "text/slain", n 'checking content-type';

ok t_cmp $dbh->selectall_arrayref
           ('SELECT data FROM p200 WHERE session=?', {},
	    substr( $loc, -32 ).':00000004')->[0]->[0],
         'POST:', n 'POST result in DB';

$resp=GET $loc;
ok t_cmp $resp->content, 'POST:', n 'POST content=POST';
ok t_cmp $resp->header('X-My-Header'), 'hallo opi', n 'response header';
ok t_cmp $resp->header('X-My-Error'), 'error', n 'response error header';
ok t_cmp $resp->content_type, 'text/slain', n 'response content-type';

$resp=POST $loc;
ok t_cmp $resp->code, 302, n 'POST => 302';
ok t_cmp $resp->header('Location'), qr#^(?!\Q$loc\E)#, n 'Location ne '.$loc;
ok t_cmp $resp->header('Location'), qr!\Q$hostport\E/proxy/mp/method\?-redirect-[A-Za-z0-9@=-]{32}$!, n 'Location';
ok t_cmp $dbh->selectall_arrayref
           ('SELECT data FROM p200 WHERE session=?', {},
	    substr( $resp->header('Location'), -32 ).':00000004')->[0]->[0],
         'POST:', n 'POST result in DB';



( run in 2.721 seconds using v1.01-cache-2.11-cpan-524268b4103 )