Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ResponseMiddleware only parses if the body is string

  • Loading branch information...
commit cb85bb01082f5bdcf1ce4effab98b766ed2aeb53 1 parent 58b7e12
@mislav authored
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/faraday_stack/response_middleware.rb
View
6 lib/faraday_stack/response_middleware.rb
@@ -32,7 +32,7 @@ def initialize(app = nil, options = {})
# Override this to modify the environment after the response has finished.
def on_complete(env)
- if process_response_type?(response_type(env))
+ if process_response_type?(response_type(env)) and parse_response?(env)
env[:body] = parse(env[:body])
end
end
@@ -62,5 +62,9 @@ def process_response_type?(type)
Regexp === pattern ? type =~ pattern : type == pattern
}
end
+
+ def parse_response?(env)
+ env[:body].respond_to? :to_str
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.