1
0
Fork 0
mirror of https://github.com/jnunemaker/httparty synced 2023-03-27 23:23:07 -04:00

Mitigates Style/IncosistentIndentation

This commit is contained in:
Thomas Nys 2015-04-18 13:44:56 +02:00
parent 1c9e129fc4
commit a37018532d
3 changed files with 39 additions and 39 deletions

View file

@ -514,30 +514,30 @@ module HTTParty
private
def perform_request(http_method, path, options, &block) #:nodoc:
options = ModuleInheritableAttributes.hash_deep_dup(default_options).merge(options)
process_headers(options)
process_cookies(options)
Request.new(http_method, path, options).perform(&block)
end
def perform_request(http_method, path, options, &block) #:nodoc:
options = ModuleInheritableAttributes.hash_deep_dup(default_options).merge(options)
process_headers(options)
process_cookies(options)
Request.new(http_method, path, options).perform(&block)
end
def process_headers(options)
if options[:headers] && headers.any?
options[:headers] = headers.merge(options[:headers])
end
def process_headers(options)
if options[:headers] && headers.any?
options[:headers] = headers.merge(options[:headers])
end
end
def process_cookies(options) #:nodoc:
return unless options[:cookies] || default_cookies.any?
options[:headers] ||= headers.dup
options[:headers]["cookie"] = cookies.merge(options.delete(:cookies) || {}).to_cookie_string
end
def process_cookies(options) #:nodoc:
return unless options[:cookies] || default_cookies.any?
options[:headers] ||= headers.dup
options[:headers]["cookie"] = cookies.merge(options.delete(:cookies) || {}).to_cookie_string
end
def validate_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(', ')}"
end
def validate_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(', ')}"
end
end
end
def self.normalize_base_uri(url) #:nodoc:

View file

@ -38,9 +38,9 @@ RSpec.describe HTTParty::CookieHash do
it "should handle '=' within cookie value" do
@cookie_hash.add_cookies("first=one=1; second=two=2==")
expect(@cookie_hash.keys).to include(:first, :second)
expect(@cookie_hash[:first]).to eq('one=1')
expect(@cookie_hash[:second]).to eq('two=2==')
expect(@cookie_hash.keys).to include(:first, :second)
expect(@cookie_hash[:first]).to eq('one=1')
expect(@cookie_hash[:second]).to eq('two=2==')
end
end

View file

@ -47,22 +47,22 @@ class SSLTestServer
private
def thread_main
until @stopping_mutex.synchronize { @stopping }
(rr, _, _) = select([@ssl_server.to_io], nil, nil, 0.1)
def thread_main
until @stopping_mutex.synchronize { @stopping }
(rr, _, _) = select([@ssl_server.to_io], nil, nil, 0.1)
next unless rr && rr.include?(@ssl_server.to_io)
next unless rr && rr.include?(@ssl_server.to_io)
socket = @ssl_server.accept
socket = @ssl_server.accept
Thread.new {
header = []
Thread.new {
header = []
until (line = socket.readline).rstrip.empty?
header << line
end
until (line = socket.readline).rstrip.empty?
header << line
end
response = <<EOF
response = <<EOF
HTTP/1.1 200 OK
Connection: close
Content-Type: application/json; charset=UTF-8
@ -70,11 +70,11 @@ Content-Type: application/json; charset=UTF-8
{"success":true}
EOF
socket.write(response.gsub(/\r\n/n, "\n").gsub(/\n/n, "\r\n"))
socket.close
}
end
@ssl_server.close
socket.write(response.gsub(/\r\n/n, "\n").gsub(/\n/n, "\r\n"))
socket.close
}
end
@ssl_server.close
end
end