diff options
| author | Ton Voon <tonvoon@users.sourceforge.net> | 2008-11-08 02:32:03 +0000 |
|---|---|---|
| committer | Ton Voon <tonvoon@users.sourceforge.net> | 2008-11-08 02:32:03 +0000 |
| commit | 6c5f781bc58cef0a28ab2dbc7eeb1391df3ba009 (patch) | |
| tree | ccc0cd52ce067193efecc1b4a05c9b86c5364a61 /plugins/tests | |
| parent | 288b742ed61bb62a210fdd3614d4e3883aa82407 (diff) | |
| download | monitoring-plugins-6c5f781bc58cef0a28ab2dbc7eeb1391df3ba009.tar.gz | |
Fixed bug where extra headers and redirect caused segfault (Dieter Van de Walle - 2089159)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2076 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/tests')
| -rwxr-xr-x | plugins/tests/check_http.t | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t index d54932e6..c5f90803 100755 --- a/plugins/tests/check_http.t +++ b/plugins/tests/check_http.t | |||
| @@ -28,7 +28,8 @@ if ($pid) { | |||
| 28 | #print "child\n"; | 28 | #print "child\n"; |
| 29 | 29 | ||
| 30 | my $d = HTTP::Daemon->new( | 30 | my $d = HTTP::Daemon->new( |
| 31 | LocalPort => $port | 31 | LocalPort => $port, |
| 32 | LocalAddr => "127.0.0.1", | ||
| 32 | ) || die; | 33 | ) || die; |
| 33 | print "Please contact me at: <URL:", $d->url, ">\n"; | 34 | print "Please contact me at: <URL:", $d->url, ">\n"; |
| 34 | while (my $c = $d->accept ) { | 35 | while (my $c = $d->accept ) { |
| @@ -57,6 +58,12 @@ if ($pid) { | |||
| 57 | $c->send_basic_header; | 58 | $c->send_basic_header; |
| 58 | $c->send_crlf; | 59 | $c->send_crlf; |
| 59 | $c->send_response($r->method.":".$r->content); | 60 | $c->send_response($r->method.":".$r->content); |
| 61 | } elsif ($r->url->path eq "/redirect") { | ||
| 62 | $c->send_redirect( "/redirect2" ); | ||
| 63 | } elsif ($r->url->path eq "/redirect2") { | ||
| 64 | $c->send_basic_header; | ||
| 65 | $c->send_crlf; | ||
| 66 | $c->send_response("redirected"); | ||
| 60 | } else { | 67 | } else { |
| 61 | $c->send_error(RC_FORBIDDEN); | 68 | $c->send_error(RC_FORBIDDEN); |
| 62 | } | 69 | } |
| @@ -73,7 +80,7 @@ if ($ARGV[0] && $ARGV[0] eq "-d") { | |||
| 73 | } | 80 | } |
| 74 | 81 | ||
| 75 | if (-x "./check_http") { | 82 | if (-x "./check_http") { |
| 76 | plan tests => 39; | 83 | plan tests => 47; |
| 77 | } else { | 84 | } else { |
| 78 | plan skip_all => "No check_http compiled"; | 85 | plan skip_all => "No check_http compiled"; |
| 79 | } | 86 | } |
| @@ -180,3 +187,23 @@ $result = NPTest->testCmd( $cmd ); | |||
| 180 | is( $result->return_code, 0, $cmd); | 187 | is( $result->return_code, 0, $cmd); |
| 181 | like( $result->output, '/^HTTP OK HTTP/1.1 200 OK - ([\d\.]+) second/', "Output correct: ".$result->output ); | 188 | like( $result->output, '/^HTTP OK HTTP/1.1 200 OK - ([\d\.]+) second/', "Output correct: ".$result->output ); |
| 182 | 189 | ||
| 190 | $cmd = "$command -u /redirect"; | ||
| 191 | $result = NPTest->testCmd( $cmd ); | ||
| 192 | is( $result->return_code, 0, $cmd); | ||
| 193 | like( $result->output, '/^HTTP OK - HTTP/1.1 301 Moved Permanently - [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 194 | |||
| 195 | $cmd = "$command -f follow -u /redirect"; | ||
| 196 | $result = NPTest->testCmd( $cmd ); | ||
| 197 | is( $result->return_code, 0, $cmd); | ||
| 198 | like( $result->output, '/^HTTP OK HTTP/1.1 200 OK - 183 bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 199 | |||
| 200 | $cmd = "$command -u /redirect -k 'follow: me'"; | ||
| 201 | $result = NPTest->testCmd( $cmd ); | ||
| 202 | is( $result->return_code, 0, $cmd); | ||
| 203 | like( $result->output, '/^HTTP OK - HTTP/1.1 301 Moved Permanently - [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 204 | |||
| 205 | $cmd = "$command -f follow -u /redirect -k 'follow: me'"; | ||
| 206 | $result = NPTest->testCmd( $cmd ); | ||
| 207 | is( $result->return_code, 0, $cmd); | ||
| 208 | like( $result->output, '/^HTTP OK HTTP/1.1 200 OK - 183 bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 209 | |||
