Skip to content

Commit

Permalink
fixes #12
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioRuiz committed Aug 7, 2019
1 parent 5eb8c75 commit c9eb347
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 13 additions & 11 deletions lib/nice_http/manage_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,21 @@ def manage_response(resp, data)
create_stats(resp) if @create_stats

begin
# this is to be able to access all keys as symbols
new_resp = Hash.new()
resp.each { |key, value|
if key.kind_of?(String)
new_resp[key.to_sym] = value
end
}
new_resp.each { |key, value|
resp[key] = value
}
# this is to be able to access all keys as symbols on Ruby < 2.6.0
if RUBY_VERSION < '2.6.0'
new_resp = Hash.new()
resp.each { |key, value|
if key.kind_of?(String)
new_resp[key.to_sym] = value
end
}
new_resp.each { |key, value|
resp[key] = value
}
end
rescue
end

#for mock_responses to be able to add outside of the header like content-type for example
if resp.kind_of?(Hash) and !resp.has_key?(:header)
resp[:header] = {}
Expand Down Expand Up @@ -162,7 +165,6 @@ def manage_response(resp, data)
@cookies[cookie_path] = Hash.new() unless @cookies.keys.include?(cookie_path)
@cookies[cookie_path][cookie_pair[0]] = cookie_pair[1]
}

@logger.info "set-cookie added to Cookie header as required"

if @headers.has_key?("X-CSRFToken")
Expand Down
2 changes: 1 addition & 1 deletion nice_http.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'nice_http'
s.version = '1.7.15'
s.version = '1.7.16'
s.summary = "NiceHttp -- simplest library for accessing and testing HTTP and REST resources. Get http logs and statistics automatically. Use hashes on your requests. Access JSON even easier."
s.description = "NiceHttp -- simplest library for accessing and testing HTTP and REST resources. Get http logs and statistics automatically. Use hashes on your requests. Access JSON even easier."
s.authors = ["Mario Ruiz"]
Expand Down

0 comments on commit c9eb347

Please sign in to comment.