Skip to content

Commit

Permalink
added time_request and time_response to response headers
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioRuiz committed Jun 5, 2019
1 parent c975521 commit f211387
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/nice_http/manage_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def manage_response(resp, data)
@response[:time_elapsed_total] = nil
end
if @start_time_net.kind_of?(Time)
@response[:time_request] = @start_time_net
@response[:time_response] = @finish_time
@response[:time_elapsed] = @finish_time - @start_time_net
@start_time_net = nil
else
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.12'
s.version = '1.7.13'
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
14 changes: 13 additions & 1 deletion spec/nice_http/get_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,15 @@
expect(resp.message).to eq "OK"
end

it "set the cookies when required" do
# todo: I need to find another ws, this one is not including set-cookie anymore
xit "set the cookies when required" do
server = "https://samples.auth0.com/"
path = "/authorize?client_id=kbyuFDidLLm280LIwVFiazOqjO3ty8KH&response_type=code"

http = NiceHttp.new(server)
http.auto_redirect = true
resp = http.get(path)
p resp.keys
expect(resp.key?(:'set-cookie')).to eq true
expect(http.cookies["/"].key?("auth0")).to eq true
end
Expand All @@ -98,4 +100,14 @@
content = File.read("./nice_http.log")
expect(content).to match /There was a problem converting to json/
end

it 'returns on headers the time_request and time_response' do
started = Time.now
resp = @http.get "/api/users?delay=1"
finished = Time.now
expect(resp.time_request >= started)
expect(resp.time_request <= finished)
expect(resp.time_response >= finished)
end

end

0 comments on commit f211387

Please sign in to comment.