Skip to content

Does PHP-VCR work with stream_context_create? #96

Closed
@tylercollier

Description

@tylercollier

I'm using the expert-sender-api library. The request in the cassette that ends up recorded is almost blank:

    request:
        method: GET
        url: [URL HERE]
        headers:
            Host: [HOST HERE]
            Content-Length: '0'

There should be a request body, and the content-length should not be zero (it's also odd it's a string, no?). Also, the method there is GET, but it should be POST. If I disable PHP-VCR, and perform a live web service call, the request goes out as I expect and then I get a proper response. So something is not right or fully handled by PHP-VCR here.

If I enabled PHP-VCR and let it send the blank request, it captures the response. As you might expect, it's a response to the blank request, but in my case, the response contains 9 headers and an XML body that I'd expect. So that part works.

The expert-sender-api library's query() method here makes use of PHP's stream_context_create I'm wondering if that has anything to do with it. I suppose not, because that's part of HTTP wrapper, which PHP-VCR explicitly states it supports.

If I manually create the cassette request, there's still another problem. Weirdly (this is directly from the php manual):

When using the HTTP wrapper, $http_response_header will be populated with the HTTP response headers. $http_response_header will be created in the local scope.

The fatal error I get with PHP-VCR is:

Undefined variable: http_response_header

That variable is from line 32. Is it possible for PHP-VCR to handle this? I know essentially how PHP-VCR works, and I can't imagine it dealing with that. Searching the source code for http_response_header yields nothing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions