httpx/test/support/requests/headers.rb
HoneyryderChuck 108d9257c8 added support for HTTP#with_ methods
these will reapply options accordingly (i.e. HTTPX.with_headers(...)).

Because we now have these, HTTPX.headers and HTTPX.timeout have been
deprecated.
2020-03-10 18:58:31 +00:00

25 lines
696 B
Ruby

# frozen_string_literal: true
module Requests
module Headers
def test_http_headers
uri = build_uri("/headers")
response = HTTPX.get(uri)
body = json_body(response)
assert body.key?("headers"), "no headers"
assert body["headers"]["Accept"] == "*/*", "unexpected accept"
response = HTTPX.with_headers("accept" => "text/css").get(uri)
body = json_body(response)
verify_header(body["headers"], "Accept", "text/css")
end
def test_http_user_agent
uri = build_uri("/user-agent")
response = HTTPX.get(uri)
body = json_body(response)
verify_header(body, "user-agent", "httpx.rb/#{HTTPX::VERSION}")
end
end
end