Module: HTTPX::Plugins::Stream::ResponseMethods

Defined in:
lib/httpx/plugins/stream.rb

Instance Method Summary collapse

Instance Method Details

#<<(data) ⇒ Object



27
28
29
30
31
# File 'lib/httpx/plugins/stream.rb', line 27

def <<(data)
  res = super
  @stream_complete = true if String(data).end_with?("\n\n")
  res
end

#complete?Boolean

Returns:

  • (Boolean)


17
18
19
20
21
# File 'lib/httpx/plugins/stream.rb', line 17

def complete?
  super ||
    stream? &&
      @stream_complete
end

#stream?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/httpx/plugins/stream.rb', line 23

def stream?
  @headers["content-type"].start_with?("text/event-stream")
end