Skip to content

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