Class: God::Conditions::HttpResponseCode

Class | God::Conditions::HttpResponseCode
In: | lib/god/conditions/http_response_code.rb
Parent: | PollCondition

Condition Symbol :http_response_code Type: Poll

Trigger based on the response from an HTTP request.

Paramaters

      Required
        +host+ is the hostname to connect [required]
        --one of code_is or code_is_not--
        +code_is+ trigger if the response code IS one of these
                  e.g. 500 or '500' or [404, 500] or %w{404 500}
        +code_is_not+ trigger if the response code IS NOT one of these
                      e.g. 200 or '200' or [200, 302] or %w{200 302}
     Optional
        +port+ is the port to connect (default 80)
        +path+ is the path to connect (default '/')
        +times+ is the number of times after which to trigger (default 1)
                e.g. 3 (times in a row) or [3, 5] (three out of fives times)
        +timeout+ is the time to wait for a connection (default 60.seconds)

Examples

Trigger if the response code from www.example.com/foo/bar is not a 200 (or if the connection is refused or times out:

      on.condition(:http_response_code) do |c|
        c.host = 'www.example.com'
        c.path = '/foo/bar'
        c.code_is_not = 200
      end

Trigger if the response code is a 404 or a 500 (will not be triggered by a connection refusal or timeout):

      on.condition(:http_response_code) do |c|
        c.host = 'www.example.com'
        c.path = '/foo/bar'
        c.code_is = [404, 500]
      end

Trigger if the response code is not a 200 five times in a row:

      on.condition(:http_response_code) do |c|
        c.host = 'www.example.com'
        c.path = '/foo/bar'
        c.code_is_not = 200
        c.times = 5
      end

Trigger if the response code is not a 200 or does not respond within 10 seconds:

      on.condition(:http_response_code) do |c|
        c.host = 'www.example.com'
        c.path = '/foo/bar'
        c.code_is_not = 200
        c.timeout = 10
      end

### Methods

new prepare reset test valid?

### Attributes

code_is | [RW] |
code_is_not | [RW] |
host | [RW] |
path | [RW] |
port | [RW] |
timeout | [RW] |
times | [RW] |

### Public Class methods

new()

### Public Instance methods

prepare()
reset()
test()
valid?()

[Validate]