mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-04 00:00:37 -04:00
* sending info on whether the session is in persistent mode to the request; * on parser, set keep-alive when persistent, at all times; * when not persistent, set keep-alive on all requests til the last; * on error recovery, when resetting to 1 request at a time, still keep alive to all requests til the last; * on next error recovery, set connection: close
52 lines
1.3 KiB
Ruby
52 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "support/http_helpers"
|
|
|
|
class HTTPTest < Minitest::Test
|
|
include HTTPHelpers
|
|
include Requests
|
|
include Head
|
|
include Get
|
|
include ChunkedGet
|
|
include WithBody
|
|
include WithChunkedBody
|
|
include Headers
|
|
include ResponseBody
|
|
include IO
|
|
include Errors
|
|
include AltSvc if ENV.key?("HTTPBIN_ALTSVC_HOST")
|
|
|
|
include Plugins::Proxy unless ENV.key?("HTTPX_NO_PROXY")
|
|
include Plugins::Authentication
|
|
include Plugins::FollowRedirects
|
|
include Plugins::Cookies
|
|
include Plugins::Compression
|
|
include Plugins::H2C
|
|
include Plugins::Retries
|
|
include Plugins::Multipart
|
|
include Plugins::Expect
|
|
|
|
def test_verbose_log
|
|
log = StringIO.new
|
|
uri = build_uri("/get")
|
|
response = HTTPX.get(uri, debug: log, debug_level: 2)
|
|
verify_status(response, 200)
|
|
log_output = log.string
|
|
# assert request headers
|
|
assert log_output.match(%r{HEADLINE: "GET .+ HTTP/1\.1"})
|
|
assert log_output.match(%r{HEADER: Accept: */*})
|
|
assert log_output.match(/HEADER: Host: \w+/)
|
|
assert log_output.match(/HEADER: Connection: close/)
|
|
# assert response headers
|
|
assert log_output.match(%r{HEADLINE: 200 HTTP/1\.1})
|
|
assert log_output.match(/HEADER: content\-type: \w+/)
|
|
assert log_output.match(/HEADER: content\-length: \d+/)
|
|
end
|
|
|
|
private
|
|
|
|
def origin(orig = httpbin)
|
|
"http://#{orig}"
|
|
end
|
|
end
|