mirror of
https://github.com/lkeme/BiliHelper-personal.git
synced 2025-12-19 09:30:10 +08:00
[fix] Curl
This commit is contained in:
parent
2d3362196c
commit
65a3ad8628
@ -15,7 +15,7 @@
|
|||||||
"clue/socket-raw": "^1.4.1",
|
"clue/socket-raw": "^1.4.1",
|
||||||
"vlucas/phpdotenv": "^4.1",
|
"vlucas/phpdotenv": "^4.1",
|
||||||
"amphp/amp": "^2.4",
|
"amphp/amp": "^2.4",
|
||||||
"lkeme/curl-future": "dev-master"
|
"lkeme/curl-future": "^0.0.1"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"authors": [
|
"authors": [
|
||||||
|
|||||||
18
composer.lock
generated
18
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "6e83be077b5af9863dab5c4affd54c0b",
|
"content-hash": "94b2a09fe75ecf7401a6694e164b252c",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "amphp/amp",
|
"name": "amphp/amp",
|
||||||
@ -246,16 +246,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "lkeme/curl-future",
|
"name": "lkeme/curl-future",
|
||||||
"version": "dev-master",
|
"version": "v0.0.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/lkeme/CurlFuture.git",
|
"url": "https://github.com/lkeme/CurlFuture.git",
|
||||||
"reference": "084f1004ba722b72755c7519932117d7fb72c214"
|
"reference": "f588d890eee745d8ecd3ee1135ac6de899381e15"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/lkeme/CurlFuture/zipball/084f1004ba722b72755c7519932117d7fb72c214",
|
"url": "https://api.github.com/repos/lkeme/CurlFuture/zipball/f588d890eee745d8ecd3ee1135ac6de899381e15",
|
||||||
"reference": "084f1004ba722b72755c7519932117d7fb72c214",
|
"reference": "f588d890eee745d8ecd3ee1135ac6de899381e15",
|
||||||
"shasum": "",
|
"shasum": "",
|
||||||
"mirrors": [
|
"mirrors": [
|
||||||
{
|
{
|
||||||
@ -280,8 +280,8 @@
|
|||||||
"email": "263068280@qq.com"
|
"email": "263068280@qq.com"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Parallel CURL Requests with PHP",
|
"description": "Parallel CURL Requests with PHP --Fork",
|
||||||
"time": "2020-01-03T16:39:17+00:00"
|
"time": "2020-01-04T13:16:47+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "monolog/monolog",
|
"name": "monolog/monolog",
|
||||||
@ -613,9 +613,7 @@
|
|||||||
"packages-dev": [],
|
"packages-dev": [],
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"stability-flags": {
|
"stability-flags": [],
|
||||||
"lkeme/curl-future": 20
|
|
||||||
},
|
|
||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
"prefer-lowest": false,
|
"prefer-lowest": false,
|
||||||
"platform": {
|
"platform": {
|
||||||
|
|||||||
@ -36,22 +36,30 @@ class Curl
|
|||||||
$new_tasks = [];
|
$new_tasks = [];
|
||||||
$results = [];
|
$results = [];
|
||||||
$url = self::http2https($url);
|
$url = self::http2https($url);
|
||||||
|
$curl_options = [
|
||||||
|
CURLOPT_HEADER => 0,
|
||||||
|
CURLOPT_ENCODING => 'gzip',
|
||||||
|
CURLOPT_IPRESOLVE => 1,
|
||||||
|
CURLOPT_RETURNTRANSFER => 1,
|
||||||
|
CURLOPT_SSL_VERIFYPEER => 0,
|
||||||
|
CURLOPT_TIMEOUT => $timeout,
|
||||||
|
CURLOPT_CONNECTTIMEOUT => $timeout,
|
||||||
|
];
|
||||||
|
if (($cookie = getenv('COOKIE')) != "") {
|
||||||
|
$curl_options[CURLOPT_COOKIE] = $cookie;
|
||||||
|
}
|
||||||
|
if (getenv('USE_PROXY') == 'true') {
|
||||||
|
$curl_options[CURLOPT_PROXY] = getenv('PROXY_IP');
|
||||||
|
$curl_options[CURLOPT_PROXYPORT] = getenv('PROXY_PORT');
|
||||||
|
}
|
||||||
foreach ($tasks as $task) {
|
foreach ($tasks as $task) {
|
||||||
$payload = $task['payload'];
|
$payload = $task['payload'];
|
||||||
$header = is_null($headers) ? self::getHeaders(self::$headers) : self::getHeaders($headers);
|
$header = is_null($headers) ? self::getHeaders(self::$headers) : self::getHeaders($headers);
|
||||||
$options = [
|
$options = [
|
||||||
'header' => $header,
|
'header' => $header,
|
||||||
'timeout' => $timeout,
|
|
||||||
'post_data' => is_array($payload) ? http_build_query($payload) : $payload
|
'post_data' => is_array($payload) ? http_build_query($payload) : $payload
|
||||||
];
|
];
|
||||||
// $options['proxy_url'] = "127.0.0.1:8888";
|
$new_task = new HttpFuture($url, $options, $curl_options);
|
||||||
if (getenv('USE_PROXY') == 'true') {
|
|
||||||
$options['proxy_url'] = "http://" . getenv('PROXY_IP') . ":" . getenv('PROXY_PORT');
|
|
||||||
}
|
|
||||||
if (($cookie = getenv('COOKIE')) != "") {
|
|
||||||
$options['header']['Cookie'] = $cookie;
|
|
||||||
}
|
|
||||||
$new_task = new HttpFuture($url, $options);
|
|
||||||
array_push($new_tasks, [
|
array_push($new_tasks, [
|
||||||
'task' => $new_task,
|
'task' => $new_task,
|
||||||
'source' => $task['source']
|
'source' => $task['source']
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user