Created
March 31, 2018 01:49
-
-
Save swarley/430912d62dbb943c7f8c34168343e013 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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