From 252c6186dfcb65e25f676d4d607495dcc0e0a0d4 Mon Sep 17 00:00:00 2001 From: Don Pflaster Date: Fri, 22 Mar 2013 12:59:07 -0400 Subject: [PATCH] Check to see if String object responds to encode before attempting --- lib/maxmind/request.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/maxmind/request.rb b/lib/maxmind/request.rb index 46a3778..7e7a2ed 100644 --- a/lib/maxmind/request.rb +++ b/lib/maxmind/request.rb @@ -60,7 +60,8 @@ def bin=(bin) def process! resp = post(query) - Maxmind::Response.new(resp.body.encode("utf-8", "iso-8859-1"), resp.code) + to_send = resp.body.respond_to?("encode") ? resp.body.encode("utf-8", "iso-8859-1") : resp.body + Maxmind::Response.new(to_send, resp.code) end def process