lib/flexirest/request.rb in flexirest-1.3.25 vs lib/flexirest/request.rb in flexirest-1.3.26

- old
+ new

@@ -269,11 +269,11 @@ @get_params ||= {} @post_params ||= {} matches.each do |token| token = token.first[1,999] target = @get_params.delete(token.to_sym) || @post_params.delete(token.to_sym) || @get_params.delete(token.to_s) || @post_params.delete(token.to_s) || "" - @url.gsub!(":#{token}", target.to_s) + @url.gsub!(":#{token}", URI.escape(target.to_s)) end end end def append_get_parameters @@ -568,10 +568,15 @@ def generate_new_object(options={}) if @response.body.is_a?(Array) || @response.body.is_a?(Hash) body = @response.body elsif is_json_response? - body = @response.body.blank? ? {} : MultiJson.load(@response.body) + begin + body = @response.body.blank? ? {} : MultiJson.load(@response.body) + rescue MultiJson::ParseError => exception + raise ResponseParseException.new(status:@response.status, body:@response.body, headers:@response.headers) + end + if options[:ignore_root] body = body[options[:ignore_root].to_s] end elsif is_xml_response? body = @response.body.blank? ? {} : Crack::XML.parse(@response.body)