);
}
// Create a connection exception if it was a specific error code.
$error = isset($connectionErrors[$easy->errno])
? new ConnectException($message, $easy->request, null, $ctx)
: new RequestException($message, $easy->request, $easy->response, null, $ctx);
return \GuzzleHttp\Promise\rejection_for($error);
}
&& (!$easy->errno || $easy->errno == 65)
) {
return self::retryFailedRewind($handler, $easy, $ctx);
}
return self::createRejection($easy, $ctx);
}
private static function createRejection(EasyHandle $easy, array $ctx)
{
static $connectionErrors = [
if (isset($easy->options['on_stats'])) {
self::invokeStats($easy);
}
if (!$easy->response || $easy->errno) {
return self::finishError($handler, $easy, $factory);
}
// Return the response if it is present and there is no error.
$factory->release($easy);
$easy = $this->factory->create($request, $options);
curl_exec($easy->handle);
$easy->errno = curl_errno($easy->handle);
return CurlFactory::finish($this, $easy, $this->factory);
}
}
callable $sync
) {
return function (RequestInterface $request, array $options) use ($default, $sync) {
return empty($options[RequestOptions::SYNCHRONOUS])
? $default($request, $options)
: $sync($request, $options);
};
}
/**
* Sends streaming requests to a streaming compatible handler while sending
callable $default,
callable $streaming
) {
return function (RequestInterface $request, array $options) use ($default, $streaming) {
return empty($options['stream'])
? $default($request, $options)
: $streaming($request, $options);
};
}
}
{
$fn = $this->nextHandler;
// Don't do anything if the request has no body.
if ($request->getBody()->getSize() === 0) {
return $fn($request, $options);
}
$modify = [];
// Add a default content-type if possible.
public static function cookies()
{
return function (callable $handler) {
return function ($request, array $options) use ($handler) {
if (empty($options['cookies'])) {
return $handler($request, $options);
} elseif (!($options['cookies'] instanceof CookieJarInterface)) {
throw new \InvalidArgumentException('cookies must be an instance of GuzzleHttp\Cookie\CookieJarInterface');
}
$cookieJar = $options['cookies'];
$request = $cookieJar->withCookieHeader($request);
if (empty($options['allow_redirects']['max'])) {
return $fn($request, $options);
}
return $fn($request, $options)
->then(function (ResponseInterface $response) use ($request, $options) {
return $this->checkRedirect($request, $options, $response);
});
}
$nextRequest->getUri()
);
}
/** @var PromiseInterface|ResponseInterface $promise */
$promise = $this($nextRequest, $options);
// Add headers to be able to track history of redirects.
if (!empty($options['allow_redirects']['track_redirects'])) {
return $this->withTracking(
$promise,
return $fn($request, $options);
}
return $fn($request, $options)
->then(function (ResponseInterface $response) use ($request, $options) {
return $this->checkRedirect($request, $options, $response);
});
}
/**
* @param RequestInterface $request
$p = new Promise([$queue, 'run']);
$value = $this->value;
$queue->add(static function () use ($p, $value, $onFulfilled) {
if (Is::pending($p)) {
try {
$p->resolve($onFulfilled($value));
} catch (\Throwable $e) {
$p->reject($e);
} catch (\Exception $e) {
$p->reject($e);
}
public function run()
{
while ($task = array_shift($this->queue)) {
/** @var callable $task */
$task();
}
}
/**
* The task queue will be run and exhausted by default when the process
private function invokeWaitFn()
{
try {
$wfn = $this->waitFn;
$this->waitFn = null;
$wfn(true);
} catch (\Exception $reason) {
if ($this->state === self::PENDING) {
// The promise has not been resolved yet, so reject the promise
// with the exception.
$this->reject($reason);
private function waitIfPending()
{
if ($this->state !== self::PENDING) {
return;
} elseif ($this->waitFn) {
$this->invokeWaitFn();
} elseif ($this->waitList) {
$this->invokeWaitList();
} else {
// If there's no wait function, then reject the promise.
$this->reject('Cannot wait on a promise that has '
$waitList = $this->waitList;
$this->waitList = null;
foreach ($waitList as $result) {
do {
$result->waitIfPending();
$result = $result->result;
} while ($result instanceof Promise);
if ($result instanceof PromiseInterface) {
$result->wait(false);
if ($this->state !== self::PENDING) {
return;
} elseif ($this->waitFn) {
$this->invokeWaitFn();
} elseif ($this->waitList) {
$this->invokeWaitList();
} else {
// If there's no wait function, then reject the promise.
$this->reject('Cannot wait on a promise that has '
. 'no internal wait function. You must provide a wait '
. 'function when constructing the promise to be able to '
return $this->then(null, $onRejected);
}
public function wait($unwrap = true)
{
$this->waitIfPending();
if ($this->result instanceof PromiseInterface) {
return $this->result->wait($unwrap);
}
if ($unwrap) {
* @throws GuzzleException
*/
public function request($method, $uri = '', array $options = [])
{
$options[RequestOptions::SYNCHRONOUS] = true;
return $this->requestAsync($method, $uri, $options)->wait();
}
/**
* Get a client configuration option.
*
$client = new \GuzzleHttp\Client($param);
$html = $client->request('GET', $url, [
'headers' => [
'Accept-Encoding' => 'gzip, deflate',
'User-Agent'=>'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:49.0) Gecko/20100101 Firefox/49.0',
'Cookie' => $this->cookie,
]
]);
$html = \Follow\Html::convertToUtf8((string)$html->getBody());
return $html;
}
{
$rawWord = $word;
///$word = "$word - (".implode("|", static::$blockWords).")";
$word = '"pan.baidu.com/s/" '.$word;
$url = "https://www.baidu.com/s?ie=utf-8&pn={$pn}&wd=".rawurlencode($word);
$html = $this->request($url);
$html = strip_tags($html, "<a><span><div>");
$this->parseAndAdd($html);
}
public function parseAndAdd($html)
public function search($keywords)
{
$keywords = trim($keywords);
$data = \App\Models\SearchHistory::where('keywords', $keywords)->first();
if (empty($data) || ($data && time() - strtotime($data->updated_at) > 7*86400)) {
\App\Modules\Search\Baidu::instance()->getSearchResult($keywords);
if ($data) {
$data->updated_at = date('Y-m-d H:i:s', time());
$data->save();
}
}
}
//$topic->title = \App\Modules\Search\Baidu::instance()->cleanTitle($topic->title);
//$topic->save();
if ($topic->view_count == 0) {
\App\Modules\Search::instance()->search($topic->title);
}
if (substr($topic->hash, 0,5) != $hash) {
return abort(404);
}
* @param array $parameters
* @return \Symfony\Component\HttpFoundation\Response
*/
public function callAction($method, $parameters)
{
return $this->{$method}(...array_values($parameters));
}
/**
* Handle calls to missing methods on the controller.
*
$parameters = $this->resolveClassMethodDependencies(
$route->parametersWithoutNulls(), $controller, $method
);
if (method_exists($controller, 'callAction')) {
return $controller->callAction($method, $parameters);
}
return $controller->{$method}(...array_values($parameters));
}
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*/
protected function runController()
{
return $this->controllerDispatcher()->dispatch(
$this, $this->getController(), $this->getControllerMethod()
);
}
/**
* Get the controller instance for the route.
{
$this->container = $this->container ?: new Container;
try {
if ($this->isControllerAction()) {
return $this->runController();
}
return $this->runCallable();
} catch (HttpResponseException $e) {
return $e->getResponse();
return (new Pipeline($this->container))
->send($request)
->through($middleware)
->then(function ($request) use ($route) {
return $this->prepareResponse(
$request, $route->run()
);
});
}
/**
*/
protected function prepareDestination(Closure $destination)
{
return function ($passable) use ($destination) {
try {
return $destination($passable);
} catch (Throwable $e) {
return $this->handleException($passable, $e);
}
};
}
$this->template->error = '';
$this->template->success = '';
$this->template->actionName= '';
$this->middleware(function ($request, $next) {
view()->share('loginUser', \App\Modules\User::instance()->checkLogin());
return $next($request);
});
view()->share('boxList', array(
view('box.notice')
));
}
try {
if (is_callable($pipe)) {
// If the pipe is a callable, then we will call it directly, but otherwise we
// will resolve the pipes out of the dependency container and call it with
// the appropriate method and arguments, returning the results back out.
return $pipe($passable, $stack);
} elseif (! is_object($pipe)) {
[$name, $parameters] = $this->parsePipeString($pipe);
// If the pipe is a string we will parse the string and resolve the class out
// of the dependency injection container. We can then build a callable and
}
throw $exception;
}
return $next($request);
}
}
// since the object we're given was already a fully instantiated object.
$parameters = [$passable, $stack];
}
$carry = method_exists($pipe, $this->method)
? $pipe->{$this->method}(...$parameters)
: $pipe(...$parameters);
return $this->handleCarry($carry);
} catch (Throwable $e) {
return $this->handleException($passable, $e);
// Putting the errors in the view for every view allows the developer to just
// assume that some errors are always available, which is convenient since
// they don't have to continually run checks for the presence of errors.
return $next($request);
}
}
// since the object we're given was already a fully instantiated object.
$parameters = [$passable, $stack];
}
$carry = method_exists($pipe, $this->method)
? $pipe->{$this->method}(...$parameters)
: $pipe(...$parameters);
return $this->handleCarry($carry);
} catch (Throwable $e) {
return $this->handleException($passable, $e);
$this->startSession($request, $session)
);
$this->collectGarbage($session);
$response = $next($request);
$this->storeCurrentUrl($request, $session);
$this->addCookieToResponse($response, $session);
if ($this->manager->shouldBlock() ||
($request->route() instanceof Route && $request->route()->locksFor())) {
return $this->handleRequestWhileBlocking($request, $session, $next);
}
return $this->handleStatefulRequest($request, $session, $next);
}
/**
* Handle the given request within session state.
*
// since the object we're given was already a fully instantiated object.
$parameters = [$passable, $stack];
}
$carry = method_exists($pipe, $this->method)
? $pipe->{$this->method}(...$parameters)
: $pipe(...$parameters);
return $this->handleCarry($carry);
} catch (Throwable $e) {
return $this->handleException($passable, $e);
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$response = $next($request);
foreach ($this->cookies->getQueuedCookies() as $cookie) {
$response->headers->setCookie($cookie);
}
// since the object we're given was already a fully instantiated object.
$parameters = [$passable, $stack];
}
$carry = method_exists($pipe, $this->method)
? $pipe->{$this->method}(...$parameters)
: $pipe(...$parameters);
return $this->handleCarry($carry);
} catch (Throwable $e) {
return $this->handleException($passable, $e);
* @param \Closure $next
* @return \Symfony\Component\HttpFoundation\Response
*/
public function handle($request, Closure $next)
{
return $this->encrypt($next($this->decrypt($request)));
}
/**
* Decrypt the cookies on the request.
*
// since the object we're given was already a fully instantiated object.
$parameters = [$passable, $stack];
}
$carry = method_exists($pipe, $this->method)
? $pipe->{$this->method}(...$parameters)
: $pipe(...$parameters);
return $this->handleCarry($carry);
} catch (Throwable $e) {
return $this->handleException($passable, $e);
{
$pipeline = array_reduce(
array_reverse($this->pipes()), $this->carry(), $this->prepareDestination($destination)
);
return $pipeline($this->passable);
}
/**
* Run the pipeline and return the result.
*
->through($middleware)
->then(function ($request) use ($route) {
return $this->prepareResponse(
$request, $route->run()
);
});
}
/**
* Gather the middleware for the given route with resolved class names.
*
});
$this->events->dispatch(new RouteMatched($route, $request));
return $this->prepareResponse($request,
$this->runRouteWithinStack($route, $request)
);
}
/**
* Run the given route within a Stack "onion" instance.
* @param \Illuminate\Http\Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public function dispatchToRoute(Request $request)
{
return $this->runRoute($request, $this->findRoute($request));
}
/**
* Find the route matching a given request.
*
*/
public function dispatch(Request $request)
{
$this->currentRequest = $request;
return $this->dispatchToRoute($request);
}
/**
* Dispatch the request to a route and return the response.
*
protected function dispatchToRouter()
{
return function ($request) {
$this->app->instance('request', $request);
return $this->router->dispatch($request);
};
}
/**
* Call the terminate method on any terminable middleware.
*/
protected function prepareDestination(Closure $destination)
{
return function ($passable) use ($destination) {
try {
return $destination($passable);
} catch (Throwable $e) {
return $this->handleException($passable, $e);
}
};
}
*/
public function handle($request, Closure $next)
{
$this->clean($request);
return $next($request);
}
/**
* Clean the request's data.
*
if ($callback($request)) {
return $next($request);
}
}
return parent::handle($request, $next);
}
/**
* Transform the given value.
*
// since the object we're given was already a fully instantiated object.
$parameters = [$passable, $stack];
}
$carry = method_exists($pipe, $this->method)
? $pipe->{$this->method}(...$parameters)
: $pipe(...$parameters);
return $this->handleCarry($carry);
} catch (Throwable $e) {
return $this->handleException($passable, $e);
null,
$this->getHeaders($data)
);
}
return $next($request);
}
/**
* Determine if the incoming request has a maintenance mode bypass cookie.
*
// since the object we're given was already a fully instantiated object.
$parameters = [$passable, $stack];
}
$carry = method_exists($pipe, $this->method)
? $pipe->{$this->method}(...$parameters)
: $pipe(...$parameters);
return $this->handleCarry($carry);
} catch (Throwable $e) {
return $this->handleException($passable, $e);
{
$pipeline = array_reduce(
array_reverse($this->pipes()), $this->carry(), $this->prepareDestination($destination)
);
return $pipeline($this->passable);
}
/**
* Run the pipeline and return the result.
*
$this->bootstrap();
return (new Pipeline($this->app))
->send($request)
->through($this->app->shouldSkipMiddleware() ? [] : $this->middleware)
->then($this->dispatchToRouter());
}
/**
* Bootstrap the application for HTTP requests.
*
public function handle($request)
{
try {
$request->enableHttpMethodParameterOverride();
$response = $this->sendRequestThroughRouter($request);
} catch (Throwable $e) {
$this->reportException($e);
$response = $this->renderException($request, $e);
}
*/
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
ConnectException
|
---|
GuzzleHttp\Exception\ConnectException: cURL error 28: Operation timed out after 5000 milliseconds with 0 bytes received (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) at /var/www/Pan/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:200 at GuzzleHttp\Handler\CurlFactory::createRejection() (/var/www/Pan/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:155) at GuzzleHttp\Handler\CurlFactory::finishError() (/var/www/Pan/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:105) at GuzzleHttp\Handler\CurlFactory::finish() (/var/www/Pan/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php:43) at GuzzleHttp\Handler\CurlHandler->__invoke() (/var/www/Pan/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php:28) at GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler\{closure}() (/var/www/Pan/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php:51) at GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler\{closure}() (/var/www/Pan/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php:37) at GuzzleHttp\PrepareBodyMiddleware->__invoke() (/var/www/Pan/vendor/guzzlehttp/guzzle/src/Middleware.php:29) at GuzzleHttp\Middleware::GuzzleHttp\{closure}() (/var/www/Pan/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php:70) at GuzzleHttp\RedirectMiddleware->__invoke() (/var/www/Pan/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php:115) at GuzzleHttp\RedirectMiddleware->checkRedirect() (/var/www/Pan/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php:72) at GuzzleHttp\RedirectMiddleware->GuzzleHttp\{closure}() (/var/www/Pan/vendor/guzzlehttp/promises/src/FulfilledPromise.php:41) at GuzzleHttp\Promise\FulfilledPromise::GuzzleHttp\Promise\{closure}() (/var/www/Pan/vendor/guzzlehttp/promises/src/TaskQueue.php:48) at GuzzleHttp\Promise\TaskQueue->run() (/var/www/Pan/vendor/guzzlehttp/promises/src/Promise.php:248) at GuzzleHttp\Promise\Promise->invokeWaitFn() (/var/www/Pan/vendor/guzzlehttp/promises/src/Promise.php:224) at GuzzleHttp\Promise\Promise->waitIfPending() (/var/www/Pan/vendor/guzzlehttp/promises/src/Promise.php:269) at GuzzleHttp\Promise\Promise->invokeWaitList() (/var/www/Pan/vendor/guzzlehttp/promises/src/Promise.php:226) at GuzzleHttp\Promise\Promise->waitIfPending() (/var/www/Pan/vendor/guzzlehttp/promises/src/Promise.php:62) at GuzzleHttp\Promise\Promise->wait() (/var/www/Pan/vendor/guzzlehttp/guzzle/src/Client.php:182) at GuzzleHttp\Client->request() (/var/www/Pan/app/Modules/Search/Base.php:34) at App\Modules\Search\Base->request() (/var/www/Pan/app/Modules/Search/Baidu.php:26) at App\Modules\Search\Baidu->getSearchResult() (/var/www/Pan/app/Modules/Search.php:23) at App\Modules\Search->search() (/var/www/Pan/app/Http/Controllers/TopicController.php:110) at App\Http\Controllers\TopicController->getDetail() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54) at Illuminate\Routing\Controller->callAction() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:45) at Illuminate\Routing\ControllerDispatcher->dispatch() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Routing/Route.php:262) at Illuminate\Routing\Route->runController() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Routing/Route.php:205) at Illuminate\Routing\Route->run() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Routing/Router.php:721) at Illuminate\Routing\Router->Illuminate\Routing\{closure}() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:128) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/var/www/Pan/app/Http/Controllers/Controller.php:39) at App\Http\Controllers\Controller->App\Http\Controllers\{closure}() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:149) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php:50) at Illuminate\Routing\Middleware\SubstituteBindings->handle() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php:49) at Illuminate\View\Middleware\ShareErrorsFromSession->handle() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php:121) at Illuminate\Session\Middleware\StartSession->handleStatefulRequest() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php:64) at Illuminate\Session\Middleware\StartSession->handle() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php:37) at Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php:67) at Illuminate\Cookie\Middleware\EncryptCookies->handle() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:103) at Illuminate\Pipeline\Pipeline->then() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Routing/Router.php:723) at Illuminate\Routing\Router->runRouteWithinStack() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Routing/Router.php:698) at Illuminate\Routing\Router->runRoute() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Routing/Router.php:662) at Illuminate\Routing\Router->dispatchToRoute() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Routing/Router.php:651) at Illuminate\Routing\Router->dispatch() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:167) at Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:128) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:21) at Illuminate\Foundation\Http\Middleware\TransformsRequest->handle() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php:40) at Illuminate\Foundation\Http\Middleware\TrimStrings->handle() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php:86) at Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:103) at Illuminate\Pipeline\Pipeline->then() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:142) at Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter() (/var/www/Pan/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:111) at Illuminate\Foundation\Http\Kernel->handle() (/var/www/Pan/public/index.php:53) |