Sha256: eb527af72c2998fe212472d0cb1df8556460a7f8c3e2d5b7da302ede6b65f3e7
Contents?: true
Size: 1.22 KB
Versions: 28
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true module HTTPX module Utils using URIExtensions module_function def now Process.clock_gettime(Process::CLOCK_MONOTONIC) end def elapsed_time(monotonic_timestamp) Process.clock_gettime(Process::CLOCK_MONOTONIC) - monotonic_timestamp end # 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 to_uri(uri) URI(uri) end else URIParser = URI::RFC2396_Parser.new def to_uri(uri) return URI(uri) unless uri.is_a?(String) && !uri.ascii_only? uri = URI(URIParser.escape(uri)) non_ascii_hostname = URIParser.unescape(uri.host) non_ascii_hostname.force_encoding(Encoding::UTF_8) idna_hostname = Punycode.encode_hostname(non_ascii_hostname) uri.host = idna_hostname uri.non_ascii_hostname = non_ascii_hostname uri end end end end
Version data entries
28 entries across 28 versions & 1 rubygems