~thirdplace/components

1a38be78951e7ff66e3d96f9c750817b0f8c3161 — Dag 1 year, 4 months ago ea67cab
fix: caching http client was not using the provided config
1 files changed, 3 insertions(+), 5 deletions(-)

M src/http/CachingHttpClient.php
M src/http/CachingHttpClient.php => src/http/CachingHttpClient.php +3 -5
@@ 32,19 32,17 @@ final class CachingHttpClient implements HttpClient
            return $cachedResponse->withHeader('thirdplace-cache', 'local hit');
        }

        $headers = [];

        if ($cachedResponse) {
            if ($cachedResponse->header('last-modified')) {
                $headers['if-modified-since'] = $cachedResponse->header('last-modified');
                $config['headers']['if-modified-since'] = $cachedResponse->header('last-modified');
            }
            if ($cachedResponse->header('etag')) {
                $headers['if-none-match'] = $cachedResponse->header('etag');
                $config['headers']['if-none-match'] = $cachedResponse->header('etag');
            }
        }

        try {
            $response = $this->client->request($method, $url, ['headers' => $headers]);
            $response = $this->client->request($method, $url, $config);

            $this->cache->set($isCachedKey, true, $this->ttl);