Sha256: 244e7439633316f02847f5a64daf89e5e4b047b3874b12e4b4c5273c75bd30b4

Contents?: true

Size: 681 Bytes

Versions: 12

Compression:

Stored size: 681 Bytes

Contents

require 'faraday'
require 'json'

module Ably
  module Rest
    module Middleware
      class FailIfUnsupportedMimeType < Faraday::Middleware
        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
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
ably-rest-1.2.7 lib/submodules/ably-ruby/lib/ably/rest/middleware/fail_if_unsupported_mime_type.rb
ably-1.2.7 lib/ably/rest/middleware/fail_if_unsupported_mime_type.rb
ably-rest-1.2.6 lib/submodules/ably-ruby/lib/ably/rest/middleware/fail_if_unsupported_mime_type.rb
ably-1.2.6 lib/ably/rest/middleware/fail_if_unsupported_mime_type.rb
ably-rest-1.2.4 lib/submodules/ably-ruby/lib/ably/rest/middleware/fail_if_unsupported_mime_type.rb
ably-1.2.4 lib/ably/rest/middleware/fail_if_unsupported_mime_type.rb
ably-rest-1.2.3 lib/submodules/ably-ruby/lib/ably/rest/middleware/fail_if_unsupported_mime_type.rb
ably-1.2.3 lib/ably/rest/middleware/fail_if_unsupported_mime_type.rb
ably-rest-1.2.2 lib/submodules/ably-ruby/lib/ably/rest/middleware/fail_if_unsupported_mime_type.rb
ably-1.2.2 lib/ably/rest/middleware/fail_if_unsupported_mime_type.rb
ably-rest-1.2.1 lib/submodules/ably-ruby/lib/ably/rest/middleware/fail_if_unsupported_mime_type.rb
ably-1.2.1 lib/ably/rest/middleware/fail_if_unsupported_mime_type.rb