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

VCRHTTPResponse should have a release_conn() method #816

Open
Antiochian opened this issue Jan 30, 2024 · 0 comments
Open

VCRHTTPResponse should have a release_conn() method #816

Antiochian opened this issue Jan 30, 2024 · 0 comments

Comments

@Antiochian
Copy link

Similar slightly to #117

The urllib3 library's response class has the method release_conn(), intended for use with connection pools:
https://urllib3.readthedocs.io/en/latest/reference/urllib3.response.html#urllib3.response.BaseHTTPResponse.release_conn

When I try to use VCR with my code that uses urllib3 connection pools, I get the following exception:

    def authenticate_user(self, response, **kwargs):
        """Handles user authentication with gssapi/kerberos"""
    
        host = urlparse(response.url).hostname
    
        try:
            auth_header = self.generate_request_header(response, host)
        except KerberosExchangeError:
            # GSS Failure, return existing response
            return response
    
        log.debug("authenticate_user(): Authorization header: {0}".format(
            auth_header))
        response.request.headers['Authorization'] = auth_header
    
        # Consume the content so we can reuse the connection for the next
        # request.
        response.content
>       response.raw.release_conn()
E       AttributeError: 'VCRHTTPResponse' object has no attribute 'release_conn'. Did you mean: '_close_conn'?

I can see that in urllib3_stubs.py we set urllib3 classes as base classes for VCRRequestsHTTPConnection and VCRRequestsHTTPSConnection.

Is the solution to add a similar snippet in urllib3_stubs.py to set the base class of `VCRHTTPResponse?

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

No branches or pull requests

1 participant