This commit is contained in:
Jaeger
2018-12-10 01:27:48 +08:00
parent 661bc3168d
commit c32736bd9e
7 changed files with 161 additions and 0 deletions

View File

@@ -23,5 +23,9 @@ class HttpServiceProvider implements ServiceProviderContract
$kernel->bind('post',function (...$args){
return HttpService::post($this,...$args);
});
$kernel->bind('postJson',function (...$args){
return HttpService::postJson($this,...$args);
});
}
}

View File

@@ -24,5 +24,9 @@ class SystemServiceProvider implements ServiceProviderContract
return $this->query()->getData($callback)->all();
});
$kernel->bind('pipe',function (Closure $callback = null){
return $callback($this);
});
}
}

View File

@@ -35,7 +35,9 @@ use Closure;
* @method QueryList encoding(string $outputEncoding,string $inputEncoding = null)
* @method QueryList get($url,$args = null,$otherArgs = [])
* @method QueryList post($url,$args = null,$otherArgs = [])
* @method QueryList postJson($url,$args = null,$otherArgs = [])
* @method QueryList use($plugins,...$opt)
* @method QueryList pipe(Closure $callback = null)
*/
class QueryList
{

View File

@@ -45,4 +45,15 @@ class HttpService
$ql->setHtml($html);
return $ql;
}
public static function postJson(QueryList $ql,$url,$args = null,$otherArgs = [])
{
$otherArgs = array_merge([
'cookies' => self::getCookieJar(),
'verify' => false
],$otherArgs);
$html = GHttp::postJson($url,$args,$otherArgs);
$ql->setHtml($html);
return $ql;
}
}