File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -162,10 +162,8 @@ def response_body
162162
163163 def data
164164 @data ||=
165- if ( body = @response [ :body ] ) && !body . strip . empty? && body . start_with? ( "{" )
166- if body . is_a? ( String ) &&
167- @response [ :response_headers ] &&
168- @response [ :response_headers ] [ :content_type ] =~ /json/
165+ if ( body = @response [ :body ] )
166+ if valid_json_body? ( body )
169167
170168 Sawyer ::Agent . serializer . decode ( body )
171169 else
@@ -174,6 +172,14 @@ def data
174172 end
175173 end
176174
175+ def valid_json_body? ( body )
176+ body . is_a? ( String ) &&
177+ @response [ :response_headers ] &&
178+ @response [ :response_headers ] [ :content_type ] =~ /json/ &&
179+ !body . strip . empty? &&
180+ body . start_with? ( "{" )
181+ end
182+
177183 def response_message
178184 case data
179185 when Hash
You can’t perform that action at this time.
0 commit comments