survivor: Httpurl Check Module

SURVIVOR: `httpurl` Check Module
About `httpurl` Dependencies Arguments Description Examples
About `httpurl`
basics |
Module Type | Scheduler | Remote
check | Yes | Yes
syntax |
         module httpurl {
           [method <string>]
           [scheme (http | https)]
           [username <string>]
           [password <password>]
           path <string>
           [query <string>]
           [query ...]
           [header <string>]
           [header ...]
           [followredirect <boolean>]
           [matchcode <number>]
           [matchheader <string>]
           [errorheader <string>]
           [matchregex <string>]
           [errorregex <string>]
         }
### Dependencies Perl Modules `HTTP::Request::Common` `LWP::UserAgent` `URI` ### Arguments
Name | Type | Value
method | optional string, default is 'GET' | HTTP method to use.
scheme | optional string, either 'http' or 'https', default is 'http' | HTTP scheme to use.
username | optional string | Username to use if authorization is required.
password | optional password | Password to use if authorization is required. Must be provided if username is provided.
path | string | Path part of URL to be retreived.
query | optional string list | Query part of URL to be retrieved. List should be `name=value` pairs.
header | optional string list | HTTP headers to send along with request.
followredirect |  | Follow a redirect returned by the server.
matchcode | optional number between 100 and 599 | Expected HTTP return code.
matchheader | optional string | String of the form `header=regex` where header is expected to be in the response header with a value matching regex. header should be lowercase.
errorheader | optional string | String of the form `header=regex` where if header is in the response header it is not expected with a value matching regex. header should be lowercase.
matchregex | optional string | Search filter expected to be in the response.
errorregex | optional string | Search filter expected not to be in the response.
1. ### Description The `httpurl` module performs an HTTP request in order to determine if the web server being contacted is returning expected results. The two regular expressions indicate a line of the retrieved document that must match (matchregex) or not be matched (errorregex) in order for the check to be considered successful. This is a different check than the one performed by the `protocol` module. The module return value is determined as follows: If matchcode is provided and the HTTP response code matches it, `MODEXEC_OK` is returned. If matchcode is provided and the HTTP response code does not match it, `MODEXEC_PROBLEM` is returned. If the HTTP response code is 200 and the provided matchregex or matchheader checks succeed, `MODEXEC_OK` is returned. If the HTTP response code is class 1xx or 3xx, `MODEXEC_NOTICE` is returned. If the HTTP response code is class 4xx or 5xx, or if the response code is 200 and the provided matchregex or matchheader is not found or the provided errorregex or errorheader is found, `MODEXEC_PROBLEM` is returned. If the response code is not recognized, `MODEXEC_WARNING` is returned. ### Examples To test that `test.cgi` is returning 200:
            module httpurl {
              path /cgi-bin/test.cgi
            }
2. To test that `/test.html` contains the text "Welcome" followed by something and not "Not Found" followed by something:
            module httpurl {
              path /test.html
              matchregex Welcome.*
              errorregex Not Found.*
            }
3. To test that `/secure/staff.html`, which is accessed via HTTPS via the virtual server `www2.site.org` and requires authentication, is returning 200:
            module httpurl {
              scheme https
              username bob
              password secret123
              path /secure/staff.html
              header Host: www2.site.org
            }
4. To test that `/cgi-bin/tets.cgi?foo=bar&baz=1` returns 302:
            module httpurl {
              path /cgi-bin/test.cgi
              query foo=bar
              query baz=1
              matchcode 302
            }
5. To test that `/cgi-bin/cookietest.cgi?value=true` sets an expected cookie:
            module httpurl {
              path /cgi-bin/cookietest.cgi
              query value=true
              matchheader set-cookie=.*value=true.*
            }
$Date: 2006/11/19 19:09:24 $ $Revision: 0.9 $ | keywords errorheader errorregex followredirect header matchcode matchheader matchregex password path query scheme username