From 0dd628338bedd53da45510f7997e6ab1d41ef5fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phil=20H=C3=B6fer?= <phil@suma-ev.de> Date: Mon, 12 Sep 2016 10:13:37 +0200 Subject: [PATCH] =?UTF-8?q?additionalHeaders=20eingef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Jobs/Search.php | 21 +++++++++++++-------- app/Models/Searchengine.php | 3 ++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/Jobs/Search.php b/app/Jobs/Search.php index af520e6e2..3bfcdbeed 100644 --- a/app/Jobs/Search.php +++ b/app/Jobs/Search.php @@ -13,7 +13,7 @@ class Search extends Job implements ShouldQueue { use InteractsWithQueue, SerializesModels; - protected $hash, $host, $port, $name, $getString, $useragent, $fp; + protected $hash, $host, $port, $name, $getString, $useragent, $fp, $additionalHeaders; protected $buffer_length = 8192; /** @@ -21,14 +21,15 @@ class Search extends Job implements ShouldQueue * * @return void */ - public function __construct($hash, $host, $port, $name, $getString, $useragent) + public function __construct($hash, $host, $port, $name, $getString, $useragent, $additionalHeaders) { - $this->hash = $hash; - $this->host = $host; - $this->port = $port; - $this->name = $name; - $this->getString = $getString; - $this->useragent = $useragent; + $this->hash = $hash; + $this->host = $host; + $this->port = $port; + $this->name = $name; + $this->getString = $getString; + $this->useragent = $useragent; + $this->additionalHeaders = $additionalHeaders; } /** @@ -220,6 +221,10 @@ class Search extends Job implements ShouldQueue $out .= "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n"; $out .= "Accept-Language: de,en-US;q=0.7,en;q=0.3\r\n"; $out .= "Accept-Encoding: gzip, deflate, br\r\n"; + foreach (explode("$#!#$", $this->additionalHeaders) as $additionalHeader) { + $out .= str_replace("$#!!#$", "$#!#$", $additionalHeader); + } + $out .= $this->additionalHeaders; $out .= "Connection: keep-alive\r\n\r\n"; # Anfrage senden: $sent = 0; diff --git a/app/Models/Searchengine.php b/app/Models/Searchengine.php index 518528fc7..a107bf68b 100644 --- a/app/Models/Searchengine.php +++ b/app/Models/Searchengine.php @@ -88,6 +88,7 @@ abstract class Searchengine $this->hash = md5($this->host . $this->getString . $this->port . $this->name); $this->resultHash = $metager->getHashCode(); $this->canCache = $metager->canCache(); + if (!isset($this->additionalHeaders)) {$this->additionalHeaders = "";} } abstract public function loadResults($result); @@ -111,7 +112,7 @@ abstract class Searchengine * Sollen diese Parallel verarbeitet werden, muss ein anderer QUEUE_DRIVER verwendet werden. * siehe auch: https://laravel.com/docs/5.2/queues */ - $this->dispatch(new Search($this->resultHash, $this->host, $this->port, $this->name, $this->getString, $this->useragent)); + $this->dispatch(new Search($this->resultHash, $this->host, $this->port, $this->name, $this->getString, $this->useragent, $this->additionalHeaders)); } } -- GitLab