@param string $verb
@param string $location

@return Response

@throws EntityException
1516
protected function sendApiCall($verb, $location)
    {
        try {
            $this->detectInvalidJsonFields();
            $response = $this->client->sendRequest($verb, $location, $this->postFields);

            $entity = $this->getItems($response->getBody());
            if (isset($entity[0])) {
                $this->setFields($entity[0]);
            }

            return $response;
        } catch (ClientException $e) {
            if ($e->getResponse() !== null) {
                $entity = $this->getItems($e->getResponse()->getBody());

                if (isset($entity[0]['validation_messages'])) {
                    throw new ValidationException(
                        $entity[0]['validation_messages'],
                        $this->postFields,
                        $e->getResponse()->getStatusCode(),
                        isset($entity[0]['errorCode']) ? $entity[0]['errorCode'] : null
                    );
                } else {
                    throw new EntityException(
                        'Exception received from api client: ' . $e->getMessage(),
                        $e->getCode(),
                        $e->getResponse()->getStatusCode(),
                        isset($entity[0]['errorCode']) ? $entity[0]['errorCode'] : null
                    );
                }
            } else {
                throw new EntityException(
                    'Exception received from api client: ' . $e->getMessage(),
                    $e->getCode()
                );
            }
        }
    }
19113
private static function getCached(CacheableInterface $verb): ResultInterface
    {
        $key = $verb->getCacheKey();
        if (array_key_exists($key, self::$cache)) {
            return self::$cache[$key];
        }
        return null;
    }
1243189
public function doRequest($request, $location, $action, $version, $one_way = 0, $options = array())
    {
        if ($this->status === self::DISABLED) {
            throw new VCRException('Hook must be enabled.', VCRException::LIBRARY_HOOK_DISABLED);
        }

        $vcrRequest = new Request('POST', $location);

        if ($version === SOAP_1_1) {
            $vcrRequest->setHeader('Content-Type', 'text/xml; charset=utf-8;');
            $vcrRequest->setHeader('SOAPAction', $action);
        } else { // >= SOAP_1_2
            $vcrRequest->setHeader(
                'Content-Type',
                sprintf('application/soap+xml; charset=utf-8; action="%s"', $action)
            );
        }

        $vcrRequest->setBody($request);

        if (!empty($options['login'])) {
            $vcrRequest->setAuthorization($options['login'], $options['password']);
        }

        /* @var \VCR\Response $response */
        $requestCallback = self::$requestCallback;
        $response = $requestCallback($vcrRequest);

        return $response->getBody();
    }
1265092
public function update(UpdateStruct $location, $locationId)
    {
        $query = $this->handler->createUpdateQuery();

        $query
            ->update($this->handler->quoteTable('ezcontentobject_tree'))
            ->set(
                $this->handler->quoteColumn('priority'),
                $query->bindValue($location->priority)
            )
            ->set(
                $this->handler->quoteColumn('remote_id'),
                $query->bindValue($location->remoteId)
            )
            ->set(
                $this->handler->quoteColumn('sort_order'),
                $query->bindValue($location->sortOrder)
            )
            ->set(
                $this->handler->quoteColumn('sort_field'),
                $query->bindValue($location->sortField)
            )
            ->where(
                $query->expr->eq(
                    $this->handler->quoteColumn('node_id'),
                    $locationId
                )
            );
        $statement = $query->prepare();
        $statement->execute();

        // Commented due to EZP-23302: Update Location fails if no change is performed with the update
        // Should be fixed with PDO::MYSQL_ATTR_FOUND_ROWS instead
        /*if ( $statement->rowCount() < 1 )
        {
            throw new NotFound( 'location', $locationId );
        }*/
    }
481328
public function sendRequest($verb, $path, $body = null)
    {
        $this->logger->info('Module: ' . __CLASS__);

        if ($body instanceof Model) {
            $body = $body->toJSON(true);
        }

        $headers = [
            'Authorization' => 'ApiKey ' . $this->config->apiKey,
            'Request-ID' => uniqid('api-request-'),
            'Content-Type' => 'application/json',
        ];

        $this->logger->info('HTTP Request: ' . strtoupper($verb) . ' ' . $this->config->apiEndpoint . $path);
        $this->logger->debug("Request Headers:\n" . print_r($headers, true));

        if (isset($body)) {
            $this->logger->debug("Request Body:\n" . $body);
        }

        $response = $this->http->request(strtoupper($verb), trim($this->config->apiEndpoint . $path), [
            'body' => $body,
            'headers' => $headers
        ]);

        $this->logger->info('HTTP Code: ' . $response->getStatusCode());

        return $response->getBody()->getContents();
    }
186380
public function pollForChallenge(string $location): Promise {
        return call(function () use ($location) {
            do {
                /** @var Response $response */
                $response = yield $this->acmeClient->get($location);
                $body = yield $response->getBody();
                $data = json_decode($body);

                if ($data->status === 'pending') {
                    if (!$response->hasHeader('retry-after')) {
                        // throw new AcmeException("Protocol Violation: No Retry-After Header!");

                        yield new Delayed(1000);
                        continue;
                    }

                    $waitTime = $this->parseRetryAfter($response->getHeader('retry-after'));
                    $waitTime = max($waitTime, 1);

                    yield new Delayed($waitTime * 1000);

                    continue;
                }

                if ($data->status === 'invalid') {
                    $errors = [];

                    foreach ($data->errors ?? [] as $error) {
                        $message = $error->title ?? '???';

                        if ($error->detail ?? '') {
                            $message .= ' (' . $error->detail . ')';
                        }

                        $errors[] = $message;
                    }

                    throw new AcmeException('Challenge marked as invalid: ' . ($errors ? \implode(', ', $errors) : ('Unknown error: ' . $body)));
                }

                if ($data->status === 'valid') {
                    break;
                }

                throw new AcmeException("Invalid challenge status: {$data->status}.");
            } while (1);
        });
    }
1087723
public function request($verb, $arguments)
    {
        $this->emit('request.start', array(
            'verb' => $verb,
            'arguments' => $arguments
        ));
        $url = $this->urlBuilder($verb, $arguments);
        $attempt = 0;
        while (true) {
            try {
                $res = $this->httpClient->get($url, $this->getHttpOptions());
                break;
            } catch (\GuzzleHttp\Exception\ConnectException $e) {
                // Thrown in case of a networking error (connection timeout, DNS errors, etc.)
                $this->emit('request.error', array(
                    'message' => $e->getMessage(),
                ));
                time_nanosleep(intval($this->sleepTimeOnError), intval($this->sleepTimeOnError * 1000000000));
            } catch (\GuzzleHttp\Exception\ServerException $e) {
                // Thrown in case of 500 errors
                $this->emit('request.error', array(
                    'message' => $e->getMessage(),
                ));
                time_nanosleep(intval($this->sleepTimeOnError), intval($this->sleepTimeOnError * 1000000000));
            }
            $attempt++;
            if ($attempt > $this->maxRetries) {
                throw new ConnectionError('Failed to get a response from the server. Max retries (' . $this->maxRetries . ') exceeded.');
            }
        }
        $body = (string) $res->getBody();
        $this->emit('request.complete', array(
            'verb' => $verb,
            'arguments' => $arguments,
            'response' => $body
        ));
        return $body;
    }
1187815
private static function addCached(CacheableInterface $verb, ResultInterface $result): void
    {
        self::$cache[$verb->getCacheKey()] = $result;
    }
722002
function ( uri, verb ) {
		if ( string.isEmpty( uri ) || string.isEmpty( verb ) ) {
			throw new Error( label.error.invalidArguments );
		}

		uri        = utility.parse( uri ).href;
		verb       = verb.toLowerCase();
		var result = false,
		    bit    = 0;

		if ( !cache.get( uri, false ) ) {
			result = undefined;
		}
		else {
			if ( regex.del.test( verb ) ) {
				bit = 1;
			}
			else if ( regex.get_headers.test( verb ) ) {
				bit = 4;
			}
			else if ( regex.put_post.test( verb ) ) {
				bit = 2;
			}
			else if ( regex.patch.test( verb ) ) {
				bit = 8;
			}

			result = Boolean( client.permissions( uri, verb ).bit & bit );
		}

		return result;
	}
608155
protected function sendRequest($verb, $params = [])
    {
        $response = $this->communicator->request($verb, $params);
        $this->checkResponseForErrors($response);
        return $response;
    }
1278316
public function getHandler(Location $location)
    {
        if ( null === $this->handlerProvider )
        {
            return new NullHandler();
        }

        return $this->handlerProvider->getHandler( $location );
    }
719912
private function do_request($verb, $path,  $data = Array(), $timeout = 10)
    {
        return $this->use_sockets ? $this->do_request_with_sockets($verb, $path, $data, $timeout) : $this->do_request_with_curl($verb, $path, $data, $timeout );
    }
154375
public function tagHttpCacheForLocation(Location $location)
    {
        $this->responseTagger->tag($location);
        $this->responseTagger->tag($location->getContentInfo());
    }
832383
protected function checkCategoryRedirect(Location $location): ?RedirectResponse
    {
        $content = $location->content;

        $internalRedirectContent = null;
        if (!$content->getField('internal_redirect')->isEmpty()) {
            $internalRedirectContent = $content->getFieldRelation('internal_redirect');
        }

        $externalRedirectValue = $content->getField('external_redirect')->value;

        if ($internalRedirectContent instanceof Content) {
            if ($internalRedirectContent->contentInfo->mainLocationId !== $location->id) {
                return new RedirectResponse(
                    $this->router->generate($internalRedirectContent),
                    RedirectResponse::HTTP_MOVED_PERMANENTLY
                );
            }
        } elseif ($externalRedirectValue instanceof UrlValue && !$content->getField('external_redirect')->isEmpty()) {
            if (mb_stripos($externalRedirectValue->link, 'http') === 0) {
                return new RedirectResponse($externalRedirectValue->link, RedirectResponse::HTTP_MOVED_PERMANENTLY);
            }

            return new RedirectResponse(
                $this->router->generate($this->getRootLocation()) . trim($externalRedirectValue->link, '/'),
                RedirectResponse::HTTP_MOVED_PERMANENTLY
            );
        }

        return null;
    }
892127
public function removeLocation(\CampaignChain\CoreBundle\Entity\Location $location)
    {
        $this->locations->removeElement($location);
    }
125226
private function createCustomUrlAddForm(Location $location): FormInterface
    {
        $customUrlAddData = new CustomUrlAddData($location);

        return $this->formFactory->addCustomUrl($customUrlAddData);
    }
490876
protected function cache($key, Builder $query, $verb = 'get')
    {
        $actualKey = $this->indexKey($key);

        $fetchData = function () use ($actualKey, $query, $verb) {
            $this->log('refreshing cache for '.get_class($this).' ('.$actualKey.')');

            return $this->callQueryVerb($query, $verb);
        };

        if ($this->enableCaching) {
            if ($this->cacheForMinutes > 0) {
                return CacheFacade::remember($actualKey, $this->cacheForMinutes, $fetchData);
            }

            return CacheFacade::rememberForever($actualKey, $fetchData);
        }

        return $fetchData();
    }