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

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

Instance Method Summary collapse

Instance Method Details

#<<(data) ⇒ Object



24
25
26
27
28
# File 'lib/httpx/plugins/stream.rb', line 24

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

#complete?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'lib/httpx/plugins/stream.rb', line 14

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

#stream?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/httpx/plugins/stream.rb', line 20

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