-
Notifications
You must be signed in to change notification settings - Fork 94
Open
Labels
Description
On my local server (wamp), my recurly requests takes more than few minutes to complete the request.
Spent few days tracing the issue, but cant put my finger on what the actual issue could be.
But changing:
$context = stream_context_create(['http' => $options]); |
$context = stream_context_create(['http' => $options]);
$result = file_get_contents($url, false, $context);
to
$guzzle = new \GuzzleHttp\Client();
$request = new \GuzzleHttp\Psr7\Request($method, $url, $headers);
$response = $guzzle
->send($request, ['body' => $body]);
$result = $response->getBody()->getContents();
Make it snappier, and
$result contains the json data.
But $http_response_header causes the issue, as with:
$http_response_header = [
"HTTP/{$response->getProtocolVersion()} {$response->getStatusCode()} {$response->getReasonPhrase()}"
];
foreach ($response->getHeaders() as $name => $values) {
$http_response_header[] = $name . ': ' . implode(', ', $values) . "\r\n";
}
It Emulates the headers, but only returns 7 headers, compared to original codes 18 headers.
Which ultimately fails the rest of the code after :
list($result, $response_header) = $this->http->execute($request->getMethod(), $request->getPath(), $request->getBodyAsJson(), $request->getHeaders()); |
Is there any fix I can use to make existing code work?
Or can you please utilize Guzzle http? Or make it pluggable?
###Update
It seems like everything is fine, was using $request instead of $response for getting headers.