From 998c83eacbbf96e1aebe8bae225738fd2b8d6a71 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 18 Aug 2020 03:55:27 +0000 Subject: [PATCH] Avoid loop situations and connection timeouts --- src/Model/Contact/Relation.php | 2 +- src/Network/HTTPRequest.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Model/Contact/Relation.php b/src/Model/Contact/Relation.php index d1e51811ff..80092e0388 100644 --- a/src/Model/Contact/Relation.php +++ b/src/Model/Contact/Relation.php @@ -166,7 +166,7 @@ class Relation } if (empty($contact)) { - $contact = Contact::getByURL($url); + $contact = Contact::getByURL($url, false); } if (empty($contact)) { diff --git a/src/Network/HTTPRequest.php b/src/Network/HTTPRequest.php index 6fcd610aad..79419d38e2 100644 --- a/src/Network/HTTPRequest.php +++ b/src/Network/HTTPRequest.php @@ -137,6 +137,8 @@ class HTTPRequest implements IHTTPRequest @curl_setopt($ch, CURLOPT_NOBODY, $opts['nobody']); } + @curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); + if (!empty($opts['timeout'])) { @curl_setopt($ch, CURLOPT_TIMEOUT, $opts['timeout']); } else { @@ -238,6 +240,8 @@ class HTTPRequest implements IHTTPRequest curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); } + @curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); + if (intval($timeout)) { curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); } else { @@ -331,6 +335,7 @@ class HTTPRequest implements IHTTPRequest curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_NOBODY, 1); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, $this->getUserAgent()); @@ -375,6 +380,7 @@ class HTTPRequest implements IHTTPRequest curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_NOBODY, 0); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, $this->getUserAgent());