Issue
I'm trying to connect to an API using Cake's HTTP Client
. But the response object that is returned is null
, no status code, no body, nothing, just null
. It's worth noting that if I visit the URL from a browser I get the desired results.
I asked a question to see if I was doing anything stupid which is here. Judging by the lack of responses I dont think I have any silly syntax errors.
So now I'm wondering what has to happen for the Cake3 HTTP Client
to return NULL
rather than a response
object? Hopefully knowing what could be going wrong will show me where to look.
Solution
Under what circumstances will Cake3's HTTP Client return a NULL response?
When the adapter returns an empty array (ie no response objects), or a non-array value. The client uses array_pop()
on the adapters return value, which would return null
in case of an empty array, or a non-array value.
In order to debug the problem, dig into the adapter code and check where things are going wrong. Unless you are using a custom adapter, that would be \Cake\Network\Http\Adapter\Stream::_send()
.
The response being malformed, like not containing a HTTP/...
header could for example be one reason for such a failure. Maybe what you have there isn't a response at all, maybe the request didn't even made it through your firewall or something, but didn't caused an error. So, I'd suggest starting with inspecting $meta
and $content
and going from there.
Answered By - ndm
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.