CRE::Http
Constants
CONNECT_TIMEOUT = ((ENV["CRE_HTTP_CONNECT_TIMEOUT_S"]? || "5").to_f).seconds
Connect/read timeouts come from env so operators can tune per environment without recompiling. Defaults are conservative for cloud APIs where 5xx blips are normal.
READ_TIMEOUT = ((ENV["CRE_HTTP_READ_TIMEOUT_S"]? || "30").to_f).seconds
RETRY_STATUSES = {408, 425, 429, 500, 502, 503, 504}.to_set
Transient HTTP statuses where retrying makes sense. We do NOT retry on 401/403/404 — those mean the request is bad, not flaky.
Class methods
request(method : String, url : String, headers : HTTP::Headers, body : String = "", label : String = "http") : HTTP::Client::Response
Single-shot HTTP request with timeouts + retry. Returns the HTTP::Client::Response. The HTTP::Client instance is created per call and closed in an ensure block so a hung peer can't pin resources past the timeout. Webmock intercepts via instance method override so test stubs continue to apply unchanged.