mirror of
https://github.com/jnunemaker/httparty
synced 2023-03-27 23:23:07 -04:00
Mitigates Style/IncosistentIndentation
This commit is contained in:
parent
1c9e129fc4
commit
a37018532d
3 changed files with 39 additions and 39 deletions
|
@ -514,30 +514,30 @@ module HTTParty
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def perform_request(http_method, path, options, &block) #:nodoc:
|
def perform_request(http_method, path, options, &block) #:nodoc:
|
||||||
options = ModuleInheritableAttributes.hash_deep_dup(default_options).merge(options)
|
options = ModuleInheritableAttributes.hash_deep_dup(default_options).merge(options)
|
||||||
process_headers(options)
|
process_headers(options)
|
||||||
process_cookies(options)
|
process_cookies(options)
|
||||||
Request.new(http_method, path, options).perform(&block)
|
Request.new(http_method, path, options).perform(&block)
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_headers(options)
|
def process_headers(options)
|
||||||
if options[:headers] && headers.any?
|
if options[:headers] && headers.any?
|
||||||
options[:headers] = headers.merge(options[:headers])
|
options[:headers] = headers.merge(options[:headers])
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def process_cookies(options) #:nodoc:
|
def process_cookies(options) #:nodoc:
|
||||||
return unless options[:cookies] || default_cookies.any?
|
return unless options[:cookies] || default_cookies.any?
|
||||||
options[:headers] ||= headers.dup
|
options[:headers] ||= headers.dup
|
||||||
options[:headers]["cookie"] = cookies.merge(options.delete(:cookies) || {}).to_cookie_string
|
options[:headers]["cookie"] = cookies.merge(options.delete(:cookies) || {}).to_cookie_string
|
||||||
end
|
end
|
||||||
|
|
||||||
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(', ')}"
|
raise UnsupportedFormat, "'#{format.inspect}' Must be one of: #{parser.supported_formats.map(&:to_s).sort.join(', ')}"
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.normalize_base_uri(url) #:nodoc:
|
def self.normalize_base_uri(url) #:nodoc:
|
||||||
|
|
|
@ -38,9 +38,9 @@ RSpec.describe HTTParty::CookieHash do
|
||||||
|
|
||||||
it "should handle '=' within cookie value" do
|
it "should handle '=' within cookie value" do
|
||||||
@cookie_hash.add_cookies("first=one=1; second=two=2==")
|
@cookie_hash.add_cookies("first=one=1; second=two=2==")
|
||||||
expect(@cookie_hash.keys).to include(:first, :second)
|
expect(@cookie_hash.keys).to include(:first, :second)
|
||||||
expect(@cookie_hash[:first]).to eq('one=1')
|
expect(@cookie_hash[:first]).to eq('one=1')
|
||||||
expect(@cookie_hash[:second]).to eq('two=2==')
|
expect(@cookie_hash[:second]).to eq('two=2==')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -47,22 +47,22 @@ class SSLTestServer
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def thread_main
|
def thread_main
|
||||||
until @stopping_mutex.synchronize { @stopping }
|
until @stopping_mutex.synchronize { @stopping }
|
||||||
(rr, _, _) = select([@ssl_server.to_io], nil, nil, 0.1)
|
(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 {
|
Thread.new {
|
||||||
header = []
|
header = []
|
||||||
|
|
||||||
until (line = socket.readline).rstrip.empty?
|
until (line = socket.readline).rstrip.empty?
|
||||||
header << line
|
header << line
|
||||||
end
|
end
|
||||||
|
|
||||||
response = <<EOF
|
response = <<EOF
|
||||||
HTTP/1.1 200 OK
|
HTTP/1.1 200 OK
|
||||||
Connection: close
|
Connection: close
|
||||||
Content-Type: application/json; charset=UTF-8
|
Content-Type: application/json; charset=UTF-8
|
||||||
|
@ -70,11 +70,11 @@ Content-Type: application/json; charset=UTF-8
|
||||||
{"success":true}
|
{"success":true}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
socket.write(response.gsub(/\r\n/n, "\n").gsub(/\n/n, "\r\n"))
|
socket.write(response.gsub(/\r\n/n, "\n").gsub(/\n/n, "\r\n"))
|
||||||
socket.close
|
socket.close
|
||||||
}
|
}
|
||||||
end
|
|
||||||
|
|
||||||
@ssl_server.close
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ssl_server.close
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue