@param $method
@param $data

@return array
@throws \Psr\Http\Client\Exception\NetworkException
@throws \Psr\Http\Client\Exception\RequestException
516590
protected function httpRequest($method, $data)
    {
        $url  = $this->getEndpoint($method);
        $body = http_build_query($data);

        $headers = [
            'Content-Type' => 'application/x-www-form-urlencoded'
        ];

        $response = $this->httpClient->request('POST', $url, $headers, $body)->getBody();

        $payload  = StringUtil::parseFuckStr($response);

        return $payload;
    }
285558
protected function request($method, array $data = array())
    {
        $auth = base64_encode($this->username . ':' . $this->password);
        $header = "Authorization: Basic $auth";
        $opts = array(
            'http' => array(
                'method' => 'GET',
                'header' => $header
            )
        );
        $ctx = stream_context_create($opts);

        $client = new \SoapClient(
            $this->endpoint . '/wsdl',
            array(
                'location' => $this->endpoint,
                'exceptions' => 1,
                'stream_context' => $ctx,
                'trace' => true
            )
        );

        $response = call_user_func_array(array($client, $method), $data);
        if (isset($response->return)) {
            return $response->return;
        }

        return null;
    }
811828
private function getTraces(RequestDataCollector $request, string $method): array
    {
        $traceRequest = Request::create(
            $request->getPathInfo(),
            $request->getRequestServer(true)->get('REQUEST_METHOD'),
            [],
            $request->getRequestCookies(true)->all(),
            [],
            $request->getRequestServer(true)->all()
        );

        $context = $this->matcher->getContext();
        $context->setMethod($method);
        $matcher = new TraceableUrlMatcher($this->routes, $context);

        return $matcher->getTracesForRequest($traceRequest);
    }
631875
public function apiGet($action, $data = [ ], $method = 'GET', $options = [ ]) {
        return $this->httpRequest($action, $this->prepareJsonPayload($data), $method, $options);
    }
188697
private function processSerializeTypeMethod(Type\Method $method, $object, array $data, string $attribute): array
    {
        $value = $object->{$method->getter()}();

        if ($this->checkNullForAttribute($value, $attribute) === false) {
            $data[$attribute] = $value;
        }

        return $data;
    }
959495
public function query($interface, $method, $data) {
        $headers = ['rpc_client_name' => $this->config[ 'name' ],
                    'rpc_token' => $this->config[ 'token' ],
                    'rpc_serialize' => $this->config[ 'serialize' ],
                    'rpc_interface' => $interface,
                    'rpc_method' => $method];
        if (IS_SWOOLE && \Co::getuid()) {
            return $this->queryCoroutine($headers, $data);
        } else {
            return $this->queryByRequest($headers, $data);
        }

    }
275025
protected function invokeService($service,$method,$data) {

            if (is_callable($this->onInvokeService)) {
                return call_user_func_array($this->onInvokeService,array($service,$method,$data));
            } else {
                throw new Exception('onInvokeService is not defined or not callable');
            }

        }
248695
protected function getResult($method, $path, array $params = null, array $data = null)
    {
        if ($params === null) {
            $params = [];
        }
        $options = [
            'query' => $this->preParseParams($params),
        ];
        if (is_array($data) && count($data) > 0) {
            $options['json'] = $data;
        }

        $response = $this->call($method, [$path, $options]);

        $responseData = $this->parseResult($response->getBody(), $response->getStatusCode());

        if ($response->getStatusCode() !== 200) {
            throw new Exception(
                $responseData['message'],
                $responseData['code'],
                null,
                (($_ =& $responseData['errors']) ?: [])
            );
        }

        return $responseData;
    }
953185
protected function getRequestDataByMethod($method = HttpMethods::GET)
    {
        switch ($method) {
            // POST method
            case HttpMethods::POST:
                $postData = array_merge($_GET, $_POST);
                return $postData ?: [];
                break;
            // PUT method
            case HttpMethods::PUT:
            // PATH method
            case HttpMethods::PATCH:
                $data = $this->cypher->decode(file_get_contents('php://input'));
                parse_str($data, $patchData);
                $patchData = array_merge($_GET, $patchData);
                return $patchData ?: [];
                break;

            // methods with empty payload
            case HttpMethods::DELETE:
            case HttpMethods::HEAD:
            case HttpMethods::OPTIONS:
                return [];
                break;

            // GET method (default)
            case HttpMethods::GET:
            default:
                return $_GET;
                break;
        }
    }
1089165
public function request($method, $scope = null, $data = null)
    {
        if (is_array($scope)) {
            $data = $scope;
            $scope = null;
        }
        $url = $scope ? $this->url.'/'.ltrim($scope, '/') : $this->url;
        $result = self::$client->request($method, $url, $data);
        if (!$scope && $result instanceof Resource) {
            // TODO: how should POST be handled here?
            foreach ($result->data() as $key => $value) {
                self::offsetSet($key, $value);
            }
        }
        return $scope ? $result : $this;
    }
117230
private function perform($action, $data)
    {
        if ($this->app->user->isGuest) {
            return [];
        }

        return Client::perform($action, $data);
    }
552080
public function request($method, $url, $data = array())
    {
        $url = Api::getFullUrl($url);

        $hooks = new Requests_Hooks();

        $hooks->register('curl.before_send', array($this, 'setCurlSslOpts'));

        $options = array(
            'auth' => array(Api::getKey(), Api::getSecret()),
            'hook' => $hooks,
            'timeout' => 60,
        );

        $headers = $this->getRequestHeaders();

        $response = Requests::request($url, $headers, $data, $method, $options);

        $this->checkErrors($response);

        return json_decode($response->body, true);
    }
1013313
public function offsetGet($method)
        {
            $methods = $this->getConsolidatedMethods();

            if (!isset($methods[$method])) {
                throw new Exception("$method, $this->class");
            }

            return $methods[$method];
        }
787389
protected function request($path, $method, array $data = array()) {
		$request = new Request();
		$response = new Response();
		$transport = $this->getTransport();

		$request->setMethod($method);
		$request->setResource($this->buildPath($path));
		$request->setHost(self::URI);
		$request->addHeader('Authorization: Basic ' . base64_encode($this->getAuthCredentials()));
		$request->addHeader('User-Agent: ' . $this->getUserAgent());

		if (count($data)) {
			$request->addHeader('Content-Type: application/json');
			$request->setContent(json_encode($data));
		}

		$transport->send($request, $response);

		return json_decode($response->getContent());
	}
882180
public static function validMethod($data, $method)
    {
        $valid = false;
        if (strstr($data, '|')) {
            foreach (explode('|', $data) as $value) {
                $valid = self::checkMethods($value, $method);
                if ($valid) {
                    break;
                }
            }
        } else {
            $valid = self::checkMethods($data, $method);
        }

        return $valid;
    }
1373817
private function getParams(Request $request, array $data = []): array
    {
        // Add default request parameters
        $data = \array_filter($data) + [
                static::PARAM_QUERY => null,
                static::PARAM_VARIABLES => null,
                static::PARAM_OPERATION_NAME => null,
            ];

        // Keep a reference to the query-string
        $qs = $request->query;

        // Override request using query-string parameters
        $query = $qs->has(static::PARAM_QUERY) ? $qs->get(static::PARAM_QUERY) : $data[static::PARAM_QUERY];
        $variables = $qs->has(static::PARAM_VARIABLES) ? $qs->get(static::PARAM_VARIABLES) : $data[static::PARAM_VARIABLES];
        $operationName = $qs->has(static::PARAM_OPERATION_NAME) ? $qs->get(static::PARAM_OPERATION_NAME) : $data[static::PARAM_OPERATION_NAME];

        // `query` parameter is mandatory.
        if (empty($query)) {
            throw new BadRequestHttpException('Must provide query parameter');
        }

        // Variables can be defined using a JSON-encoded object.
        // If the parsing fails, an exception will be thrown.
        if (\is_string($variables)) {
            $variables = \json_decode($variables, true);

            if (\JSON_ERROR_NONE !== \json_last_error()) {
                throw new BadRequestHttpException('Variables are invalid JSON');
            }
        }

        return [
            static::PARAM_QUERY => $query,
            static::PARAM_VARIABLES => $variables,
            static::PARAM_OPERATION_NAME => $operationName,
        ];
    }
205778
public function requestCurl($url, $method = 'GET', $data = [])
    {
        $data_string = json_encode($data);

        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
                'Content-Type: application/json',
                'Authorization: Bearer ' . $this->token)
        );

        $result = curl_exec($ch);
        $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        $result = json_decode($result);

        $result = array_merge((array)$result, ["status_code" => $httpcode]);

        if ($httpcode == 401 || $httpcode == 403) {
            throw new UnauthorizedException("Unauthorized");
        } elseif ($httpcode > 403) {
            throw new \Exception("Status_code: " . $httpcode);
        }

        return $result;
    }