Skip to content

Instantly share code, notes, and snippets.

@swarley
Created March 31, 2018 01:49
Show Gist options
  • Save swarley/430912d62dbb943c7f8c34168343e013 to your computer and use it in GitHub Desktop.
Save swarley/430912d62dbb943c7f8c34168343e013 to your computer and use it in GitHub Desktop.
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.5") && ENV['OS'] =~ /Windows/i
module RestClient
module Utils
def self.cgi_parse_header(line)
parts = _cgi_parseparam(';' + line).to_a
key = parts[0]
pdict = {}
while (p = parts.shift)
i = p.index('=')
if i
name = p[0...i].strip.downcase
value = p[i+1..-1].strip
if value.length >= 2 && value[0] == '"' && value[-1] == '"'
value = value[1...-1]
value = value.gsub('\\\\', '\\').gsub('\\"', '"')
end
pdict[name] = value
end
end
[key, pdict]
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment