Permalink
Browse files

this was causing failure; check request for content_type first

  • Loading branch information...
1 parent d3c16c0 commit 0d08ea2b1186708badbfa02365dd29a57a12e3a6 @danchoi committed May 9, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/http_service/request.rb
@@ -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))

0 comments on commit 0d08ea2

Please sign in to comment.