Sha256: ad48a255a8dcbacf407dcc4fb17d14ba538777de82ebf4cf5074720a1a78d8d1

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

require 'arachni/rpc'

# @note Needs `ENV['WEB_SERVER_DISPATCHER']` in the format of `host:port`.
#
# {WebServerManager}-API-compatible client for the {WebServerAgent}.
#
# Delegates test webserver creation to the machine running {WebServerAgent},
# for hosts that lack support for fast servers (like Windows, which can't run
# Thin, Puma etc.).
#
# @author Tasos "Zapotek" Laskos <tasos.laskos@gmail.com>
class WebServerClient < Arachni::RPC::Proxy
    include Singleton

    def initialize( options = {} )
        @host, port = ENV['WEB_SERVER_DISPATCHER'].split( ':' )

        Arachni::Reactor.global.run_in_thread if !Arachni::Reactor.global.running?

        client = Arachni::RPC::Client.new( host: @host, port: port )
        super client, 'server'
    end

    def protocol_for( name )
        name.to_s.include?( 'https' ) ? 'https' : 'http'
    end

    def address_for( name )
        @host
    end

    def up?( name )
        Typhoeus.get(
            url_for( name, false ),
            ssl_verifypeer: false,
            ssl_verifyhost: 0,
            forbid_reuse:   true
        ).code != 0
    end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cuboid-0.1.3 spec/support/lib/web_server_client.rb
cuboid-0.1.2 spec/support/lib/web_server_client.rb
cuboid-0.1.1 spec/support/lib/web_server_client.rb
cuboid-0.1.0 spec/support/lib/web_server_client.rb