Skip to content

Commit

Permalink
this was causing failure; check request for content_type first
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Choi committed May 9, 2012
1 parent d3c16c0 commit 0d08ea2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/http_service/request.rb
Expand Up @@ -14,7 +14,7 @@ def self.create_request(res)
end
body = res.delete :body
request_id = DB[:requests].insert res
original_encoding = res[:content_type][/charset=(.*)/, 1] || 'UTF-8'
original_encoding = res[:content_type] && res[:content_type][/charset=(.*)/, 1] || 'UTF-8'
puts "Detected original encoding: #{original_encoding}"
body.force_encoding(original_encoding)
DB[:urls].filter(url: res[:url]).update(last_request_id: request_id, last_body: body.encode('UTF-8', undef: :replace, invalid: :replace))
Expand Down

0 comments on commit 0d08ea2

Please sign in to comment.