Method: Lightstreamer::PostRequest.execute_multiple

Defined in:
lib/lightstreamer/post_request.rb

.execute_multiple(url, bodies) ⇒ Array<LightstreamerError, nil>

Sends a POST request to the specified Lightstreamer URL that concatenates multiple individual POST request bodies into one to avoid sending lots of individual requests. The return value is an array with one entry per body and indicates the error state returned by the server for that body’s request, or ‘nil` if no error occurred.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/lightstreamer/post_request.rb', line 29

def execute_multiple(url, bodies)
  response = Excon.post url, body: bodies.join("\r\n"), expects: 200, connect_timeout: 15

  response_lines = response.body.split("\n").map(&:strip)

  errors = []
  errors << parse_error(response_lines) until response_lines.empty?

  raise LightstreamerError if errors.size != bodies.size

  errors
rescue Excon::Error => e
  raise Errors::ConnectionError, e.message
end