Method: HTTPX::AltSvc.cached_altsvc_set

Defined in:
lib/httpx/altsvc.rb

.cached_altsvc_set(origin, entry) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/httpx/altsvc.rb', line 19

def cached_altsvc_set(origin, entry)
  now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  @altsvc_mutex.synchronize do
    return if @altsvcs[origin].any? { |altsvc| altsvc["origin"] == entry["origin"] }

    entry["TTL"] = Integer(entry["ma"]) + now if entry.key?("ma")
    @altsvcs[origin] << entry
    entry
  end
end