From bd58352117430da47b76cf9d63e7a72fd44e5626 Mon Sep 17 00:00:00 2001 From: Jaeger Date: Tue, 26 Sep 2017 17:54:29 +0800 Subject: [PATCH] update http plugin --- src/Services/HttpService.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Services/HttpService.php b/src/Services/HttpService.php index 6dba7b7..226c985 100644 --- a/src/Services/HttpService.php +++ b/src/Services/HttpService.php @@ -7,13 +7,28 @@ namespace QL\Services; +use GuzzleHttp\Cookie\CookieJar; use Jaeger\GHttp; use QL\QueryList; class HttpService { + protected static $cookieJar = null; + + public static function getCookieJar() + { + if(self::$cookieJar == null) + { + self::$cookieJar = new CookieJar(); + } + return self::$cookieJar; + } + public static function get(QueryList $ql,$url,$args = null,$otherArgs = []) { + $otherArgs = array_merge([ + 'cookies' => self::getCookieJar() + ],$otherArgs); $html = GHttp::get($url,$args,$otherArgs); $ql->setHtml($html); return $ql; @@ -21,6 +36,9 @@ class HttpService public static function post(QueryList $ql,$url,$args = null,$otherArgs = []) { + $otherArgs = array_merge([ + 'cookies' => self::getCookieJar() + ],$otherArgs); $html = GHttp::post($url,$args,$otherArgs); $ql->setHtml($html); return $ql;