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

Expose Request object so we can see if a replay occurred. #759

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lewisdawson
Copy link

@lewisdawson lewisdawson commented Aug 12, 2023

In some cases, we need to determine if the actual request was invoked or the cached version was returned. In order to do that, we need to do an evolution of #394. We need to reconstruct the underlying Request object:

import vcr

def make_vcr_request(req):
      body = req.read().decode("utf-8")
      uri = str(req.url)
      headers = dict(req.headers)
      return vcr.Request(req.method, uri, body, headers)


self._current_request_used_cache = self.cassete.can_play_response_for(make_vcr_request(request))

To do that, we need VCR's Request object exposed for use outside the package.

This PR simply exposes that Request object for use. Open to thoughts on how to better accomplish this by folks that know this tool better.

@lewisdawson
Copy link
Author

@kevin1024 Any interest in merging this PR? It's a very simple change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant