class Ably::Rest::Middleware::FailIfUnsupportedMimeType

Public Instance Methods

on_complete(env) click to toggle source
# File lib/submodules/ably-ruby/lib/ably/rest/middleware/fail_if_unsupported_mime_type.rb, line 8
def on_complete(env)
  unless env.response_headers['Ably-Middleware-Parsed'] == true
    # Ignore empty body with success status code for no body response
    return if env.body.to_s.empty? && env.status == 204

    unless (500..599).include?(env.status)
      raise Ably::Exceptions::InvalidResponseBody,
            "Content Type #{env.response_headers['Content-Type']} is not supported by this client library"
    end
  end
end