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
Does PHP-VCR work with stream_context_create? #96
Comments
Regarding the "there's still another problem". I just ran a different test with PHP-VCR off and not cassette loaded. I received a response using |
Thank you very much. Indeed the stream wrapper interception is only tested with GET requests. Header support was added quite recently. The response headers seem to be indeed not recorded. Definitely some work and tests to be done here :-/ thank you for pointing this out. This should be fixed. I would be very happy to merge a pull request as I'm again limited on time. |
The |
I will work on the stream wrapper with POSTs and submit a pull request. |
I've been looking into this. I think the problem I found originally was because the server I was connecting to is sending an intermediate
Unfortunately, I don't know how to test this in the tests. Doing the above actually throws away the @adri, I'd love your in-depth PHP knowledge on how to handle the $http_response_header situation. As I noted from the linked documentation, it's a local variable that's magically brought into existence by PHP when using the stream wrappers. How can PHP-VCR invoke this behavior? My googling got me nowhere! |
For anyone who is interested in the |
This is a hard one. I'm just brainstorming a bit... It is possible to overwrite There are projects like PHP-Parser which can be used to parse PHP source code. We could implement a check if some stream wrapper function is called and I think it could be solved but it requires work and lots of testing. |
As this hasn't been worked on in years, I think now is a good time to close this issue. If anyone wants to work on this, or any other objective, in the future, please open an new issue. |
I'm using the expert-sender-api library. The request in the cassette that ends up recorded is almost blank:
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'sstream_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):
The fatal error I get with PHP-VCR is:
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.The text was updated successfully, but these errors were encountered: