Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http resource: prevent repeat calls during a control with multiple tests #2108

Merged
merged 1 commit into from
Aug 30, 2017

Conversation

mivok
Copy link
Contributor

@mivok mivok commented Aug 30, 2017

Currently, if you check two properties of a http resource, such as
status and body, two different http requests are made to the server.
However, the response is already stored in an instance variable, so this
change just checks to see if a response is already available and uses it
rather than making another http request.

The following is an example control that will demonstrate the issue (run python -mSimpleHTTPServer to start a web server listening on port 8000 and see the requests made):

control 'foo-1' do
  describe http('http://127.0.0.1:8000') do
    its('status') { should cmp 200 }
    its('body') { should_not cmp 'foo' }
  end
end

@mivok mivok requested a review from a team as a code owner August 30, 2017 14:34
Currently, if you check two properties of a http resource, such as
status and body, two different http requests are made to the server.
However, the response is already stored in an instance variable, so this
change just checks to see if a response is already available and uses it
rather than making another http request.

Signed-off-by: Mark Harrison <mark@mivok.net>
@adamleff adamleff added the Type: Bug Feature not working as expected label Aug 30, 2017
@adamleff adamleff changed the title Use stored http resource response (if any) http resource: prevent repeat calls during a control with multiple tests Aug 30, 2017
Copy link
Contributor

@adamleff adamleff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot, @mivok!

@adamleff adamleff requested a review from a team August 30, 2017 18:04
Copy link
Contributor

@arlimus arlimus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet thank you!! @mivok

@arlimus arlimus merged commit ef42e2e into master Aug 30, 2017
@arlimus arlimus deleted the mh/httpcache branch August 30, 2017 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Feature not working as expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants