@param string $method
@param string $path
@param array $query
@param array $body

@param string $type
@return mixed
972206
public function request($method, $path, $query, $body = [], $type = 'json')
    {
        // reset errors
        $this->errorMessages = [];

        $query['wt'] = 'json';
        $request = [
            'Accept' => 'application/json',
            'query' => $query
        ];

        if ($method != 'GET') {
            $request[$type] = $body;
        }

        try {
            $res = $this->client->request($method, $path, $request);

            return json_decode($res->getBody()->getContents(), true);
        } catch (RequestException $e) {
            if ($e->getResponse() === null) {
                $this->logError($e->getMessage());

                return false;
            }

            // 4xx
            if ($e->getResponse()->getStatusCode() == 400) {
                $content = $e->getResponse()->getBody()->getContents();
                $this->logError($content);

                return json_decode($content, true);
            }

            if ($e->getResponse()->getStatusCode() === 404) {
                $this->logError('404. Path: '.$e->getRequest()->getUri()->getPath(). " doesn't exist");

                return false;
            }

            $this->logError($e->getMessage());

            return false;
        }
    }
1233581
public static function createRequest($method, $path, $body = [], array $headers = [])
    {
        return new Request($method, $path, $body, $headers);
    }
1198429
private function getJsonResponseBody($method, $uri)
    {
        $body = [];

        $response = $this->httpClient->request($method, $uri);
        if ($response->getStatusCode() == 200) {
            $body = json_decode($response->getBody());
        }

        return $body;
    }
1115055
public function request($path, $method = Request::GET, $data = array(), array $query = array(), $contentType = Request::DEFAULT_CONTENT_TYPE)
    {
        if ($this->stopwatch) {
            $this->stopwatch->start('es_request', 'phlexible_elastica');
        }

        $start = microtime(true);
        $response = parent::request($path, $method, $data, $query, $contentType);
        $responseData = $response->getData();

        if (isset($responseData['took']) && isset($responseData['hits'])) {
            $this->logQuery($path, $method, $data, $query, $start, $response->getEngineTime(), $responseData['hits']['total']);
        } else {
            $this->logQuery($path, $method, $data, $query, $start, 0, 0);
        }

        if ($this->stopwatch) {
            $this->stopwatch->stop('es_request');
        }

        return $response;
    }
336355
private function _buildRequest($method, $path, $body = null, $contentType = null)
	{
		// copy default headers
		$headers = $this->_headers;

		// add Content-Type header if provided
		if ($contentType)
			$headers []= new HeaderField('Content-Type', $contentType);

		$request = new Request(
			$method,
			$this->_url->getUrlForRelativePath($path),
			$headers,
			$body
		);

		// pass the request through the filter chain
		foreach($this->_filters as $filter)
		{
			$request = $filter->request($request);
		}

		return $request;
	}
983924
public function call($path, $method, $queryParams, $httpBody = null, $headers = array())
    {
        $this->logRequestParams($path, $method, $queryParams, $httpBody, $headers);

        $url = $this->prepareUrl($path, $queryParams);

        $headers = $this->prepareHeaders($headers);

        $this->prepareCurl($method, $httpBody, $headers, $url);

        list($httpHeaders, $httpBody, $responseInfo) = $this->sendRequest();

        if (!$this->keepAlive) {
            $this->closeCurlConnection();
        }

        $this->logResponse($httpBody, $responseInfo, $httpHeaders);

        return new ResponseObject(array(
            'code'    => $responseInfo['http_code'],
            'headers' => $httpHeaders,
            'body'    => $httpBody,
        ));
    }
1005057
protected function send(string $method, $path, array $headers = [], $body = []): Contracts\Response
    {
        if ($this instanceof Contracts\Filterable) {
            $body = $this->filterRequest($body);
        }

        $endpoint = ($path instanceof Contracts\Endpoint)
                        ? $this->getApiEndpoint($path->getPath())->addQuery($path->getQuery())
                        : $this->getApiEndpoint($path);

        $message = $this->responseWith(
            $this->client->send($method, $endpoint, $headers, $body)
        );

        return $this->interactsWithResponse($message);
    }
877175
public function method($method = null, $path = '/')
    {
        $parameters = array();

        $parameters['path'] = $path;

        if($method)
            $parameters['method'] = $method;

        $route = $this->factory->createRoute($this, null, $parameters);

        $this->addRoute($route);

        return $route;
    }
1963
public function request(string $path, array $params = null, string $method = null, $body = null, array $headers = null):ResponseInterface{

		parse_str(parse_url($this->apiURL.$path, PHP_URL_QUERY), $query);

		$query['v'] = $this::API_VERSIONDATE;
		$query['m'] = 'foursquare';

		return parent::request(explode('?', $path)[0], array_merge($params ?? [], $query), $method, $body, $headers);
	}
1056624
public function getRequestSchema(string $path, string $method): Schema
    {
        return $this->getPath($path)->getOperation($method)->getRequestSchema();
    }
133127
private function getResult($url, $body, $type, $method)
    {
        $data = $this->connection($url, $body, $type, $method);
        if (isset($data) && !empty($data)) {
            $result = $data;
        } else {
            $result = '没有返回数据';
        }

        return $result;
    }
642475
public function match(string $query, string $method = null)
    {
        $this->arguments = [];
        $this->methodMatched = null;
        $this->pathMatched = null;

        $matcher = new RouteMatcher();
        $res = $matcher->match(
            $this->mount,
            $this->path,
            $this->getAbsolutePath(),
            $query,
            $this->method,
            $method
        );
        $this->arguments = $matcher->arguments;
        $this->methodMatched = $matcher->methodMatched;
        $this->pathMatched = $matcher->pathMatched;

        return $res;
    }
1364722
private function request($method, $uri, $body = array())
    {
        try {
            $res = $this->client->request($method, $uri, $body);
            return json_decode($res->getBody());
        } catch(RequestException $e){
            $res = VariableUtil::json2Array(
                json_decode($e->getResponse()->getBody()->getContents())[0]
            );
            /*
             * If the session expired, then we must request a new token with the
             * refresh token.
             */
            if(isset($res['errorCode']) && $res['errorCode'] == 'INVALID_SESSION_ID'){
                $this->refreshToken($method, $uri, $body);
            } else {
                throw new ExternalApiException($e->getMessage(), $e->getCode(), $e);
            }
        }
    }
816501
public function request($path, $method = Request::GET, $data = [], array $query = [])
    {
        return $this->_client->request('_snapshot/'.$path, $method, $data, $query);
    }
1316981
public function request($path, array $body = [], $method = 'GET', array $extraHeaders = [])
    {
        $uri = $this->determineRequestUriFromPath($path);
        /** @var AbstractToken $token */
        $token = $this->storage->retrieveAccessToken($this->service());

        if ($token->isExpired()) {
            throw new ExpiredTokenException(
                sprintf(
                    'Token expired on %s at %s',
                    date('m/d/Y', $token->getEndOfLife()),
                    date('h:i:s A', $token->getEndOfLife())
                )
            );
        }

        // add the token where it may be needed
        if (static::AUTHORIZATION_METHOD_HEADER_OAUTH === $this->getAuthorizationMethod()) {
            $extraHeaders = array_merge(['Authorization' => 'OAuth ' . $token->getAccessToken()], $extraHeaders);
        } elseif (static::AUTHORIZATION_METHOD_QUERY_STRING === $this->getAuthorizationMethod()) {
            $uri->getQuery()->modify(['access_token' => $token->getAccessToken()]);
        } elseif (static::AUTHORIZATION_METHOD_QUERY_STRING_V2 === $this->getAuthorizationMethod()) {
            $uri->getQuery()->modify(['oauth2_access_token' => $token->getAccessToken()]);
        } elseif (static::AUTHORIZATION_METHOD_QUERY_STRING_V3 === $this->getAuthorizationMethod()) {
            $uri->getQuery()->modify(['apikey' => $token->getAccessToken()]);
        } elseif (static::AUTHORIZATION_METHOD_HEADER_BEARER === $this->getAuthorizationMethod()) {
            $extraHeaders = array_merge(['Authorization' => 'Bearer ' . $token->getAccessToken()], $extraHeaders);
        }

        $extraHeaders = array_merge($this->getExtraApiHeaders(), $extraHeaders);

        return $this->httpRequest($uri, $body, $extraHeaders, $method);
    }
147872
protected function _writeData($path, $data, $method = 'PUT') 
    {
        $jsonData = json_encode($data);
        $header = array(
            'Content-Type: ' . $this->_contentType,
            'Content-Length: ' . strlen($jsonData)
        );
        $this->_addHeaderAuthentication($header);

        try {
            $ch = $this->_getCurlHandler($path, $method);
            curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
            $return = $this->_parseCurlResponse(curl_exec($ch));
            curl_close($ch);
        } catch (\Exception $e) {
            $return = null;
        }
        return $return;
    }
940930
public function buildRequest($method, $path, $body = null, $queryStrings = null, $conn = null, $queryMode = null, array $headers = array())
    {
        $request = new Request();
        $connection = $this->connectionManager->getConnection($conn);
        $request->setMethod(strtoupper($method));
        $request->setPath($path);
        $request->setBody($body);
        $request->setQueryStrings($queryStrings);
        $request->setConnection($connection->getAlias());
        $request->setQueryMode($queryMode);
        $request->setHeaders($headers);
        if ($connection->isAuth()) {
            $request->setAuthMode(true);
            $request->setUser($connection->getAuthUser());
            $request->setPassword($connection->getAuthPassword());
        }
        $url = $connection->getBaseUrl().$path;
        $request->setUrl($url);

        return $request;
    }