You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
My custom HTTP Adapter class. Any suggestions are welcome.
<?php
/**
* This class abstracts away all the PHP-level HTTP
* code. This allows us to easily mock out the HTTP
* calls in BaseClient by injecting a mocked version of
* this adapter.
*/
namespace MyApp;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
use Recurly\HttpAdapterInterface;
/**
* @codeCoverageIgnore
*/
class HttpAdapter implements HttpAdapterInterface
{
private static $_default_options = [
'ignore_errors' => true
];
/**
* Performs HTTP request
*
* @param string $method HTTP method to use
* @param string $url Fully qualified URL
* @param string $body The request body
* @param array $headers HTTP headers
*
* @return array The API response as a string and the headers as an array
*/
public function execute($method, $url, $body, $headers): array
{
// The Content-Length header is required by Recurly API infrastructure
$headers['Content-Length'] = strlen($body);
$guzzle = new Client();
$request = new Request($method, $url, $headers);
$response = $guzzle
->send($request, ['body' => $body]);
$http_response_header = [
"HTTP/{$response->getProtocolVersion()} {$response->getStatusCode()} {$response->getReasonPhrase()}"
];
foreach ($response->getHeaders() as $name => $values) {
$http_response_header[] = $name . ': ' . implode(', ', $values);
}
$result = $response->getBody()->getContents();
return [$result, $http_response_header];
}
}
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:
recurly-client-php/lib/recurly/http_adapter.php
Line 45 in 8c311c0
to
Make it snappier, and
$result contains the json data.
But $http_response_header causes the issue, as with:
It Emulates the headers, but only returns 7 headers, compared to original codes 18 headers.
Which ultimately fails the rest of the code after :
recurly-client-php/lib/recurly/base_client.php
Line 97 in 8c311c0
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.
The text was updated successfully, but these errors were encountered: