diff --git a/lib/yajl/http_stream.rb b/lib/yajl/http_stream.rb index ff94b4af..30f4f63c 100644 --- a/lib/yajl/http_stream.rb +++ b/lib/yajl/http_stream.rb @@ -4,6 +4,7 @@ require 'yajl' require 'yajl/version' unless defined? Yajl::VERSION require 'uri' +require 'cgi' module Yajl # This module is for making HTTP requests to which the response bodies (and possibly requests in the near future) @@ -101,7 +102,7 @@ def self.request(method, uri, opts = {}, &block) default_headers["Content-Type"] = opts["Content-Type"] || "application/x-www-form-urlencoded" body = opts.delete(:body) if body.is_a?(Hash) - body = body.keys.collect {|param| "#{URI.escape(param.to_s)}=#{URI.escape(body[param].to_s)}"}.join('&') + body = body.keys.collect {|param| "#{CGI.escape(param.to_s)}=#{CGI.escape(body[param].to_s)}"}.join('&') end default_headers["Content-Length"] = body.length end