module Protocol::HTTP::URL
def self.encode(value, prefix = nil)
def self.encode(value, prefix = nil) case value when Array return value.map {|v| self.encode(v, "#{prefix}[]") }.join("&") when Hash return value.map {|k, v| self.encode(v, prefix ? "#{prefix}[#{escape(k.to_s)}]" : escape(k.to_s)) }.reject(&:empty?).join('&') when nil return prefix else raise ArgumentError, "value must be a Hash" if prefix.nil? return "#{prefix}=#{escape(value.to_s)}" end end