Sha256: b0d5f8e5f72b06c85176fdb173cf563d80008cc9ad7ddf565f5c18ae21509622
Contents?: true
Size: 689 Bytes
Versions: 21
Compression:
Stored size: 689 Bytes
Contents
# frozen_string_literal: true module HTTPX module Plugins module Stream module InstanceMethods def stream headers("accept" => "text/event-stream", "cache-control" => "no-cache") end end module ResponseMethods def complete? super || stream? && @stream_complete end def stream? @headers["content-type"].start_with?("text/event-stream") end def <<(data) res = super @stream_complete = true if String(data).end_with?("\n\n") res end end end register_plugin :stream, Stream end end
Version data entries
21 entries across 21 versions & 1 rubygems