Sha256: a3fd1f7d711f0d1eb546e0d98eb2f78780754380f8c355a4a822a05d55394135
Contents?: true
Size: 1.03 KB
Versions: 17
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true module HTTPX module Utils using URIExtensions module_function # The value of this field can be either an HTTP-date or a number of # seconds to delay after the response is received. def parse_retry_after(retry_after) # first: bet on it being an integer Integer(retry_after) rescue ArgumentError # Then it's a datetime time = Time.httpdate(retry_after) time - Time.now end if RUBY_VERSION < "2.3" def uri(*args) URI(*args) end else URIParser = URI::RFC2396_Parser.new def uri(uri) return Kernel.URI(uri) unless uri.is_a?(String) && !uri.ascii_only? uri = Kernel.URI(URIParser.escape(uri)) non_ascii_hostname = URIParser.unescape(uri.host) non_ascii_hostname.force_encoding(Encoding::UTF_8) idna_hostname = DomainName.new(non_ascii_hostname).hostname uri.host = idna_hostname uri.non_ascii_hostname = non_ascii_hostname uri end end end end
Version data entries
17 entries across 17 versions & 1 rubygems