Codebase list libpoe-component-sslify-perl / e745765
start of work on mire's testcase Apocalypse 13 years ago
1 changed file(s) with 26 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
00 #!/usr/bin/perl
1
2 # Test contributed by mire@irc which used this to hit the WRITE_WANTS_READ case
3 # mire created package Ub because he couldn't reproduce it with poco-cl-http :(
4 # tweaked slightly to turn it into a real testcase ( not done yet )
15
26 BEGIN {
37 # sub POE::Kernel::ASSERT_DEFAULT () { 1 }
812
913 use strict;
1014 use warnings;
11 use Data::Dumper;
12 use Time::HiRes qw|time sleep|;
13 use POE;
15 use POE 1.310;
1416
1517 use Test::More;
16 plan skip_all => "AUTHOR TEST";
18 BEGIN {
19 plan skip_all => "AUTHOR TEST";
20 }
1721
1822 our $DEBUG=0;
1923
2024 package Ub;
2125 use strict;
2226 use warnings;
23 use Data::Dumper;
24 use HTTP::Parser;
25 use HTTP::Response;
26 use Time::HiRes qw|time sleep|;
27 use POE qw(Component::Client::TCP Filter::Stream Filter::HTTPChunk);
27 use POE qw( Component::Client::TCP Filter::Stream );
2828 use POE::Component::SSLify qw( Client_SSLify );
29
30 # non-core deps
31 BEGIN {
32 eval "use POE::Filter::HTTPChunk; use HTTP::Parser; use HTTP::Response;";
33 if ( $@ ) {
34 use Test::More;
35 plan skip_all => "Unable to load deps: $@";
36 }
37 }
38
2939 sub new {
3040 my $this = shift;
3141 my %p = @_;
103113
104114 # Disconnect if SSL failed.
105115 if ($@) {
106 print Dumper [$@]
107 if $main::DEBUG;
116 warn $@ if $main::DEBUG;
108117 return;
109118 }
110119 # Return the SSL-ified socket.
222231 $port = 443;
223232 $do_ssl = 1;
224233
225 $cont = <<'EOE'
234 $cont = <<'EOF';
226235 GET /get.php HTTP/1.1
227236 Host: osadmin.com
228237 User-Agent: proba 123
229238 Connection: close
230239
231240
232 EOE
233 ;
241 EOF
242
234243 }
235244 $kernel->post('ub', 'r', 'test_res', \$cont, $host, $port, $do_ssl);
236245
240249 $kernel->refcount_decrement($_[SESSION]->ID, 'test');
241250 my $cont = ${$dat->{'content'}};
242251 chomp $cont;
243 print Dumper $cont;
252 warn $cont;
244253 die "HIT BUG" if length $cont == 0;
245 $kernel->yield('test'); return;
246 print "test_res has " . Dumper $dat;
254 $kernel->yield('test');
255 return;
247256 },
248257 },)->ID;
249258