Module: HTTPX::Plugins::ServerSentEvents::InstanceMethods

Defined in:
lib/httpx/plugins/server_sent_events.rb,
sig/plugins/server_sent_events.rbs

Instance Method Summary collapse

Instance Method Details

#build_request ⇒ Object



50
51
52
53
54
55
56
57
# File 'lib/httpx/plugins/server_sent_events.rb', line 50

def build_request(*)
  super.tap do |request|
    if request.options.event_stream
      request.headers["accept"] = "text/event-stream"
      request.headers["cache-control"] = "no-cache"
    end
  end
end

#request(**options) ⇒ Object

sends a stream request.



44
45
46
47
48
# File 'lib/httpx/plugins/server_sent_events.rb', line 44

def request(*, **options)
  options[:stream] = true if options[:event_stream]

  super
end