Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Add timeout when reading sites #21

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "kasp3r/link-preview",
"name": "freegle/link-preview",
"type": "library",
"description": "Link preview library for PHP",
"keywords": ["php","url","scraping"],
Expand All @@ -14,7 +14,7 @@
],
"require": {
"php": ">=5.6",
"guzzlehttp/guzzle": "^6.2"
"guzzlehttp/guzzle": "^7.4.5"
},
"require-dev": {
"phpunit/phpunit": "^5.3"
Expand Down
3 changes: 2 additions & 1 deletion src/LinkPreview/Reader/GeneralReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class GeneralReader implements ReaderInterface
public function getClient()
{
if (!$this->client) {
$this->client = new Client([RequestOptions::COOKIES => true]);
// Add a 30s timeout as a fallback - some sites block us indefinitely and never return.
$this->client = new Client([RequestOptions::COOKIES => true, timeout => 30]);
}

return $this->client;
Expand Down