mirror of
https://github.com/jnunemaker/httparty
synced 2023-03-27 23:23:07 -04:00
Adds editorconfig
This commit is contained in:
parent
9ff17bc6ad
commit
57a6bd6e1d
14 changed files with 87 additions and 48 deletions
18
.editorconfig
Normal file
18
.editorconfig
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
; This file is for unifying the coding style for different editors and IDEs.
|
||||||
|
; More information at http://EditorConfig.org
|
||||||
|
|
||||||
|
root = true
|
||||||
|
[*]
|
||||||
|
end_of_line = lf
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[**.rb]
|
||||||
|
indent_size = 2
|
||||||
|
indent_style = spaces
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[**.xml]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[**.html]
|
||||||
|
trim_trailing_whitespace = false
|
|
@ -593,7 +593,8 @@ module HTTParty
|
||||||
|
|
||||||
def validate_format
|
def validate_format
|
||||||
if format && parser.respond_to?(:supports_format?) && !parser.supports_format?(format)
|
if format && parser.respond_to?(:supports_format?) && !parser.supports_format?(format)
|
||||||
raise UnsupportedFormat, "'#{format.inspect}' Must be one of: #{parser.supported_formats.map(&:to_s).sort.join(', ')}"
|
supported_format_names = parser.supported_formats.map(&:to_s).sort.join(', ')
|
||||||
|
raise UnsupportedFormat, "'#{format.inspect}' Must be one of: #{supported_format_names}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -91,7 +91,14 @@ module HTTParty
|
||||||
host = clean_host(uri.host)
|
host = clean_host(uri.host)
|
||||||
port = uri.port || (uri.scheme == 'https' ? 443 : 80)
|
port = uri.port || (uri.scheme == 'https' ? 443 : 80)
|
||||||
if options.key?(:http_proxyaddr)
|
if options.key?(:http_proxyaddr)
|
||||||
http = Net::HTTP.new(host, port, options[:http_proxyaddr], options[:http_proxyport], options[:http_proxyuser], options[:http_proxypass])
|
http = Net::HTTP.new(
|
||||||
|
host,
|
||||||
|
port,
|
||||||
|
options[:http_proxyaddr],
|
||||||
|
options[:http_proxyport],
|
||||||
|
options[:http_proxyuser],
|
||||||
|
options[:http_proxypass]
|
||||||
|
)
|
||||||
else
|
else
|
||||||
http = Net::HTTP.new(host, port)
|
http = Net::HTTP.new(host, port)
|
||||||
end
|
end
|
||||||
|
|
|
@ -39,7 +39,9 @@ module HTTParty
|
||||||
if value.empty?
|
if value.empty?
|
||||||
normalized_keys << ["#{key}[]", '']
|
normalized_keys << ["#{key}[]", '']
|
||||||
else
|
else
|
||||||
normalized_keys = value.to_ary.flat_map { |element| normalize_keys("#{key}[]", element) }
|
normalized_keys = value.to_ary.flat_map do |element|
|
||||||
|
normalize_keys("#{key}[]", element)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
elsif value.respond_to?(:to_hash)
|
elsif value.respond_to?(:to_hash)
|
||||||
stack << [key, value.to_hash]
|
stack << [key, value.to_hash]
|
||||||
|
@ -52,7 +54,9 @@ module HTTParty
|
||||||
if child_value.respond_to?(:to_hash)
|
if child_value.respond_to?(:to_hash)
|
||||||
stack << ["#{parent}[#{child_key}]", child_value.to_hash]
|
stack << ["#{parent}[#{child_key}]", child_value.to_hash]
|
||||||
elsif child_value.respond_to?(:to_ary)
|
elsif child_value.respond_to?(:to_ary)
|
||||||
child_value.to_ary.each { |v| normalized_keys << normalize_keys("#{parent}[#{child_key}][]", v).flatten }
|
child_value.to_ary.each do |v|
|
||||||
|
normalized_keys << normalize_keys("#{parent}[#{child_key}][]", v).flatten
|
||||||
|
end
|
||||||
else
|
else
|
||||||
normalized_keys << normalize_keys("#{parent}[#{child_key}]", child_value).flatten
|
normalized_keys << normalize_keys("#{parent}[#{child_key}]", child_value).flatten
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,12 +9,12 @@ module HTTParty
|
||||||
duplicate = hash.dup
|
duplicate = hash.dup
|
||||||
|
|
||||||
duplicate.each_pair do |key, value|
|
duplicate.each_pair do |key, value|
|
||||||
duplicate[key] = if value.is_a?(Hash)
|
if value.is_a?(Hash)
|
||||||
hash_deep_dup(value)
|
duplicate[key] = hash_deep_dup(value)
|
||||||
elsif value.is_a?(Proc)
|
elsif value.is_a?(Proc)
|
||||||
duplicate[key] = value.dup
|
duplicate[key] = value.dup
|
||||||
else
|
else
|
||||||
value
|
duplicate[key] = value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,8 @@ module Net
|
||||||
|
|
||||||
def parse(response_header)
|
def parse(response_header)
|
||||||
header = response_header['www-authenticate']
|
header = response_header['www-authenticate']
|
||||||
.gsub(/qop=(auth(?:-int)?)/, 'qop="\\1"')
|
|
||||||
|
header = header.gsub(/qop=(auth(?:-int)?)/, 'qop="\\1"')
|
||||||
|
|
||||||
header =~ /Digest (.*)/
|
header =~ /Digest (.*)/
|
||||||
params = {}
|
params = {}
|
||||||
|
|
|
@ -14,7 +14,11 @@ module HTTParty
|
||||||
@headers = Headers.new(response.to_hash)
|
@headers = Headers.new(response.to_hash)
|
||||||
|
|
||||||
if request.options[:logger]
|
if request.options[:logger]
|
||||||
logger = ::HTTParty::Logger.build(request.options[:logger], request.options[:log_level], request.options[:log_format])
|
logger = ::HTTParty::Logger.build(
|
||||||
|
request.options[:logger],
|
||||||
|
request.options[:log_level],
|
||||||
|
request.options[:log_format]
|
||||||
|
)
|
||||||
logger.format(request, self)
|
logger.format(request, self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -312,8 +312,12 @@ RSpec.describe HTTParty::ConnectionAdapter do
|
||||||
|
|
||||||
context 'as well as proxy user and password' do
|
context 'as well as proxy user and password' do
|
||||||
let(:options) do
|
let(:options) do
|
||||||
{http_proxyaddr: '1.2.3.4', http_proxyport: 8080,
|
{
|
||||||
http_proxyuser: 'user', http_proxypass: 'pass'}
|
http_proxyaddr: '1.2.3.4',
|
||||||
|
http_proxyport: 8080,
|
||||||
|
http_proxyuser: 'user',
|
||||||
|
http_proxypass: 'pass'
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#proxy_user' do
|
describe '#proxy_user' do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue