httpx/test/support/http_helpers.rb
HoneyryderChuck 43016795f3 introducing the :no_proxy option
can be passed in the `:proxy` option hash, and receives domains, as
strings, which requests should not go through the proxy.
2022-08-05 22:37:52 +01:00

29 lines
554 B
Ruby

# frozen_string_literal: true
require_relative "../test_helper"
require_relative "assertion_helpers"
module HTTPHelpers
include ResponseHelpers
private
def build_uri(suffix = "/", uri_origin = origin)
"#{uri_origin}#{suffix || "/"}"
end
def json_body(response)
raise response.error if response.is_a?(HTTPX::ErrorResponse)
JSON.parse(response.body.to_s)
end
def httpbin
ENV.fetch("HTTPBIN_HOST", "nghttp2.org/httpbin")
end
def httpbin_no_proxy
URI(ENV.fetch("HTTPBIN_NO_PROXY_HOST", "httpbin.org"))
end
end