Check if based on the API result we should try
to re-run the same request with HTTP instead of HTTPS.

@author Vova Feldman (@svovaf)
@since  1.1.6

@param $result

@return bool
4491
private static function should_try_with_http( $result ) {
			if ( ! Freemius_Api_WordPress::IsHttps() ) {
				return false;
			}

			return ( ! is_object( $result ) ||
			         ! isset( $result->error ) ||
			         ! isset( $result->error->code ) ||
			         ! in_array( $result->error->code, array(
				         'curl_missing',
				         'cloudflare_ddos_protection',
				         'maintenance_mode',
				         'squid_cache_block',
				         'too_many_requests',
			         ) ) );

		}
136278
protected function match(ResultInterface $result)/*# : bool */
    {
        $path = trim($result->getRequest()->getServerInfo('path_info'), ' /');
        if (count($parts = explode('/', $path)) > 1) {
            // set status
            $result->setStatus(Status::OK);

            // parameters
            $controller = array_shift($parts);
            $action = array_shift($parts);
            if (count($parts) % 2) {
                $result->setStatus(Status::BAD_REQUEST);
                return false;
            }

            $params = [];
            foreach ($parts as $i => $val) {
                if (0 === $i % 2) {
                    $params[$val] = $parts[$i + 1];
                }
            }
            $result->setParameter($params);
            $result->setHandler([$controller, $action]);

            return true;
        }
        $result->setStatus(Status::BAD_REQUEST);
        return false;
    }
70833
private function postExecute($result): ExecutionResult
    {
        if ($result instanceof Promise) {
            $result = $this->promiseAdapter->wait($result);
        }

        $this->checkExecutionResult($result);

        return $this->dispatcher->dispatch(Events::POST_EXECUTOR, new ExecutorResultEvent($result))->getResult();
    }
747051
private function transformResult($result)
    {
        if ($this->actualDriver() === self::DRIVER_PREDIS && $result instanceof Status) {
            $result = $result->getPayload() === 'OK';
        }
        return $result;
    }
1027374
protected function setResult(Api\Result $result)
	{
		$this->total = $result->getTotal();
		$this->offset = 0;
		$this->max = $result->getIssuesCount();
		$this->issues = $result->getIssues();
		$this->startAt++;
	}
1266000
public function sendResult($result)
    {
        if (@ob_get_length()) {
            @ob_end_clean();
        }
        if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false) {
            header('Content-Type: application/json; charset=' . APP_CHARSET, true);
        } else {
            header('Content-Type: text/plain; charset=' . APP_CHARSET, true);
        }
        echo json_encode($result);
        die();
    }
791818
protected function checkReturn($result)
    {
        // 返回[ServerRequestInterface $req, ResponseInterface $res]
        if (!is_array($result) ||
            $result[0] instanceof ServerRequestInterface === false ||
            $result[1] instanceof ResponseInterface === false) {
            throw new \UnexpectedValueException(
                i18n(
                    'Middleware must return a array, the first element is %s and then second is %s.',
                    ServerRequestInterface::class,
                    ResponseInterface::class
                )
            );
        }
    }
775223
public function is_error($result = null)
    {
        if ($result !== null) {
            return $result === false ? $this->db_error_msg : null;
        }

        return $this->db_error ? $this->db_error_msg : null;
    }
171687
private function processResult(array $result)
    {
        $this->checkResponseStatus($result['http_code']);

        // Get decoded response data
        $responseArr = json_decode($result['response'], true);

        $this->checkJsonError();

        return $responseArr;
    }
809838
protected function filterResult(Result $result)
    {
        $request = $result->getData('request') ?: array();
        foreach (array('AccountNumber', 'RoutingNumber') as $key) {
            if (array_key_exists($key, $request)) {
                $request[$key] = '[filtered]';
            }
        }

        $result->setData('request', $request);

        return $result;
    }
74876
public function setResult($result): self
    {
        $this->_result = $result;
        $this->_hasResult = true;

        return $this;
    }
1335458
private function resultToResponse($result) : Response
  {
    switch (true) {
      // Response object
      case $result instanceof Response:
        return $result;
      // String -> transform to response
      case is_string($result) || is_numeric($result):
        return new Response($result);
      // Uri -> transform to redirect response
      case $result instanceof Uri:
        return new RedirectResponse($uri);
      // Array -> transform to json response
      case is_array($result) || is_object($result):
        return new JsonResponse($result);
      default:
        throw new \InvalidArgumentException('Invalid route handler return value');
    }
  }
556754
public function buildResponse($result) {
        if ($result === false) {
            if ($curlErrorNumber = curl_errno($this->_ch)) {
                $curlErrorString = curl_error($this->_ch);
                $this->_error($curlErrorString);

                $exception = new ConnectionErrorException('Unable to connect to "'.$this->uri.'": '
                        . $curlErrorNumber . ' ' . $curlErrorString);

                $exception->setCurlErrorNumber($curlErrorNumber)
                    ->setCurlErrorString($curlErrorString);

                throw $exception;
            }

            $this->_error('Unable to connect to "'.$this->uri.'".');
            throw new ConnectionErrorException('Unable to connect to "'.$this->uri.'".');
        }

        $info = curl_getinfo($this->_ch);

        // Remove the "HTTP/1.x 200 Connection established" string and any other headers added by proxy
        $proxy_regex = "/HTTP\/1\.[01] 200 Connection established.*?\r\n\r\n/si";
        if ($this->hasProxy() && preg_match($proxy_regex, $result)) {
            $result = preg_replace($proxy_regex, '', $result);
        }

        $response = explode("\r\n\r\n", $result, 2 + $info['redirect_count']);

        $body = array_pop($response);
        $headers = array_pop($response);

        return new Response($body, $headers, $this, $info);
    }
225794
public function not($result)
    {
        if (\is_callable($result)) {
            $result = $result();
        }

        if ($this->can_proceed() && $result === true) {
            $this->shortcircuit = true;
        }

        return $this;
    }
470572
protected function onJobCompleted(string $result) : bool
    {
        $this->replySocket->send(json_encode([
            'request' => 'job_completed',
            'worker_id' => $this->workerId,
            'job_id' => $this->jobId,
            'result' => $result
        ]));
        $response = $this->replySocket->recv();
        $this->jobId = null;
        return ($response === 'ok');
    }
1286844
protected function checkErrorsInCmdResult($result) {
		$errors = preg_grep("/ERROR/", $result->output);

		if ($errors) {
			$message = array_map(function ($error) {
				return preg_replace("/^.*ERROR: (.*) \[\] \[\]$/", "$1", $error);
			}, $errors);

			$result->errorCode = 1;
			$result->output = $message;

			throw new CmdException($result);
		}
	}
1110271
protected function checkForSslRecordChanges($domain, $result)
    {
        if (! $ssl_history = History::where('meta', $domain)->first()) {
            return;
        }

        if ($ssl_history->record['valid'] !== $result['certificates']['information'][0]['valid_now']) {
            if (! $result['certificates']['information'][0]['valid_now']) {
                $this->eye->status()->setSick('ssl_'.$domain);
                return $this->eye->notifier()->alert(new Invalid(['domain' => $domain]));
            }
        }

        if ($ssl_history->record['revoked'] !== $result['certificates']['information'][0]['revoked']) {
            if ($result['certificates']['information'][0]['revoked']) {
                $this->eye->status()->setSick('ssl_'.$domain);
                return $this->eye->notifier()->alert(new Revoked(['domain' => $domain]));
            }
        }

        if ($ssl_history->record['expires_soon'] !== $result['certificates']['information'][0]['expires_soon']) {
            if ($result['certificates']['information'][0]['expires_soon']) {
                $this->eye->status()->setSick('ssl_'.$domain);
                return $this->eye->notifier()->alert(new Expiring(['domain' => $domain,
                                                                   'valid_to' => $result['certificates']['information'][0]['valid_to']]));
            }
        }

        if ($ssl_history->record['grade'] !== $result['results']['grade']) {
            return $this->eye->notifier()->alert(new GradeChange(['domain' => $domain,
                                                                  'old_grade' => $ssl_history->record['grade'],
                                                                  'new_grade' => $result['results']['grade']]));
        }

        $this->eye->status()->setHealthy('ssl_'.$domain);
    }