Sha256: 59302898a1a5706e56bb87d821d3799aa308dfb5ea0de3b9ee8af6dbf09a6f9d

Contents?: true

Size: 1.41 KB

Versions: 5

Compression:

Stored size: 1.41 KB

Contents

require 'typhoeus'

module Selenium
module WebDriver
module Remote
module Http

# The default client uses Threads to track timeout and we don't want that,
# each threads uses about 1MB of RAM.
#
# However, this one results in memory violations on Windows, so it should only
# be used on *nix.
class Typhoeus < Common

    private

    def request( verb, url, headers, payload )
        url = url.to_s

        headers.delete 'Content-Length'

        options = {
            headers:        headers,
            maxredirs:      MAX_REDIRECTS,
            followlocation: true,

            timeout:        Arachni::Options.browser_cluster.job_timeout,

            nosignal:       true,

            # Small trick to cancel out http_proxy env variables which would
            # otherwise be honoured by libcurl and hinder browser communications.
            proxy:          ''
        }

        case verb
            when :post, :put
                options[:body] = payload.to_s

            when :get, :delete, :head
            else
                raise Error::WebDriverError, "Unknown HTTP verb: #{verb.inspect}"
        end

        response = ::Typhoeus::Request.send( verb, url, options )

        if response.timed_out?
            raise Timeout::Error, "Request timed out: #{verb} #{url}\n#{payload}"
        end

        create_response response.code, response.body, response.headers['Content-Type']
    end

end

end
end
end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
arachni-1.6.1.3 lib/arachni/selenium/webdriver/remote/typhoeus.rb
arachni-1.6.1.2 lib/arachni/selenium/webdriver/remote/typhoeus.rb
arachni-1.6.1.1 lib/arachni/selenium/webdriver/remote/typhoeus.rb
arachni-1.6.1 lib/arachni/selenium/webdriver/remote/typhoeus.rb
arachni-1.6.0 lib/arachni/selenium/webdriver/remote/typhoeus.rb