update http plugin

This commit is contained in:
Jaeger 2017-09-26 17:54:29 +08:00
parent c3f8a48357
commit bd58352117

View File

@ -7,13 +7,28 @@
namespace QL\Services; namespace QL\Services;
use GuzzleHttp\Cookie\CookieJar;
use Jaeger\GHttp; use Jaeger\GHttp;
use QL\QueryList; use QL\QueryList;
class HttpService 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 = []) public static function get(QueryList $ql,$url,$args = null,$otherArgs = [])
{ {
$otherArgs = array_merge([
'cookies' => self::getCookieJar()
],$otherArgs);
$html = GHttp::get($url,$args,$otherArgs); $html = GHttp::get($url,$args,$otherArgs);
$ql->setHtml($html); $ql->setHtml($html);
return $ql; return $ql;
@ -21,6 +36,9 @@ class HttpService
public static function post(QueryList $ql,$url,$args = null,$otherArgs = []) public static function post(QueryList $ql,$url,$args = null,$otherArgs = [])
{ {
$otherArgs = array_merge([
'cookies' => self::getCookieJar()
],$otherArgs);
$html = GHttp::post($url,$args,$otherArgs); $html = GHttp::post($url,$args,$otherArgs);
$ql->setHtml($html); $ql->setHtml($html);
return $ql; return $ql;