Skip to content

Commit

Permalink
Clean up response content prior to parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisroberts committed Mar 13, 2015
1 parent ae6ddff commit ef9e80b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/miasma/types/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ def format_response(result, extract_body=true)
extracted_headers = Smash[result.headers.map{|k,v| [Utils.snake(k), v]}]
if(extract_body)
body_content = result.body.to_s
body_content.encode!('UTF-8', 'binary',
:invalid => :replace,
:undef => :replace,
:replace => ''
)
if(extracted_headers[:content_type].to_s.include?('json'))
extracted_body = from_json(body_content) || body_content
elsif(extracted_headers[:content_type].to_s.include?('xml'))
Expand Down

0 comments on commit ef9e80b

Please sign in to comment.