log the response and return the result of the configured handler method.

@param  Zend_Http_Response $response
@param  string $uri
@return string response body or empty
13632
protected function _processResponse(Zend_Http_Response $response, $uri)
    {
        $this->_status = $response->getStatus();
        $config = $this->_getHandlerConfig($this->_getHandlerKey($response));
        $logMethod = isset($config['logger']) ? $config['logger'] : 'debug';
        $logData = array_merge(['rom_request_url' => $uri], $this->_logAppContext);
        $this->_logger->$logMethod('Received response from.', $this->_context->getMetaData(__CLASS__, $logData));
        $responseData = $logData;
        $responseData['rom_response_body'] = $response->asString();
        $logMessage = 'Response data.';
        $this->_logger->debug($logMessage, $this->_context->getMetaData(__CLASS__, $responseData));
        if (!$response->getBody()) {
            $logMessage = "Received response with no body from {$uri} with status {$this->_status}.";
            $this->_logger->warning($logMessage, $this->_context->getMetaData(__CLASS__, $logData));
        }
        $callbackConfig = isset($config['callback']) ? $config['callback'] : array();
        $callbackConfig['parameters'] = array($response);
        return Mage::helper('radial_core')->invokeCallBack($callbackConfig);
    }
728198
public function handle($uri = null)
    {
        try {
            $returnedResponse = parent::handle($uri);
            return $this->handleWeb($returnedResponse);
        } catch (Throwable $e) {
            /** @noinspection PhpUnhandledExceptionInspection */
            return $this->handleException($e);
        }
    }
524250
private function getHttpResponse(&$header, &$response)
    {
        if (isset($header) && is_array($header) && (0 < count($header))) {
            $response = new HttpResponse($header);
            return true;
        }

        return false;
    }
102474
public function log($statusResponse = null) {
    $statusResponse = $this->getResponse('status', $statusResponse);
    $uri = trim($statusResponse['uri'], '/');

    return $this->get("$uri/logs");
  }
1047826
private function checkResponse($response)
    {
        $hasRequestError = false;
        if (preg_match('/4\d\d/', $response->getStatusCode())) {
            $this->log('error', "Invalid API key or password");
            $this->addError(self::ERROR_HTTP_AUTHENTICATION_ERROR, false);
            $hasRequestError = true;
        } elseif (preg_match('/5\d\d/', $response->getStatusCode())) {
            $this->log('error', "Gateway error - HTTP " . $response->getStatusCode());
            $this->addError(self::ERROR_HTTP_SERVER_ERROR);
            $hasRequestError = true;
        } elseif ($response->getError()) {
            $this->log('error', "Connection error: " . $response->getError());
            $this->addError(self::ERROR_CONNECTION_ERROR);
            $hasRequestError = true;
        }

        if ($hasRequestError) {
            throw new RequestException(sprintf("Last HTTP response status code: %s", $response->getStatusCode()));
        }
    }
700649
public function makeSingle(Response $response)
    {
        if (!$response->getSuccess()) {
            return null;
        }

        $result = $this->getResultFromResponse($response);

        return $result[0] ?? null;
    }
71959
private function getRedirectResponse(ServerRequestInterface $request, UriInterface $uri, ResponseInterface $response)
    {
        //Fix the basePath
        $generator = BasePath::getGenerator($request);

        if ($generator !== null) {
            $uri = $uri->withPath($generator($uri->getPath()));
        }

        return $response
            ->withStatus($this->redirectStatus)
            ->withHeader('Location', (string) $uri);
    }
468853
protected function checkResponse(Response $response)
    {
        $status = $response->getStatusCode();
        $reason = $response->getReasonPhrase();
        switch ($status) {
            case '403':
                throw new Exceptions\GeocodioAuthError($reason);
                break;

            case '422':
                throw new Exceptions\GeocodioDataError($reason);
                break;

            case '500':
                throw new Exceptions\GeocodioServerError($reason);
                break;

            case '200':
                return $response;
                break;

            default:
                throw new Exceptions\GeocodioException("There was a problem with your request - $reason");
                break;
        }
    }
246783
private function handleResponse($response)
    {

        if ($response instanceof View) {
            $content = $response->render();
        } elseif ($response instanceof Response) {
            $content = $response->getContent();
        } elseif ($response instanceof Request) {
            $content = $response->getResponse()->getContent();
        } elseif (is_string($response)) {
            $content = $response;
        } else {
            $content = false;
        }

        return $content;
    }
991517
private function processResponse(Response $response)
    {
        $response = $response->getBody()->getContents();
        $response = json_decode($response, true);

        return $response;
    }
772930
protected function processResult(Response $response)
    {
        $content = $response->getContent();
        if (strpos($content, "callback(") === 0) {
            $count = 0;
            $jsonData = preg_replace('/^callback\(\s*(\\{.*\\})\s*\);$/is', '\1', $content, 1, $count);
            if ($count === 1) {
                $response->setContent($jsonData);
            }
        }
    }
840598
function process_response($request, $response)
    {
        if (! isset($request->user) || $request->user->isAnonymous()) {
            return $response;
        }
        if ($request->user_space->touched) {
            if ($request->user_space->id > 0) {
                $request->user_space->update();
            } else {
                $request->user_space->create();
            }
        }
        return $response;
    }
292080
public function completedResponse(JsonResponse $response)
    {
        $data = $response->getData();
        $data->success = true;
        $data->uuid = $this->request->get('dzuuid');
        $response->setData($data);

        return $response;
    }
684349
public function updateFromResponse(Response $response, $uri = null)
    {
        $this->updateFromSetCookie($response->getHeader('Set-Cookie', false), $uri);
    }
474654
public function execute(\Owl\Http\Request $request, \Owl\Http\Response $response)
    {
        if ($router = $this->getDelegateRouter($request)) {
            return $router->execute($request, $response);
        }

        try {
            if (!$handlers = $this->getMiddlewareHandlers($request)) {
                $this->respond($request, $response);
            } else {
                $handlers[] = function ($request, $response) {
                    $this->respond($request, $response);

                    yield true;
                };

                $this->middleware->execute([$request, $response], $handlers);
            }
        } catch (\Exception $exception) {
            if ($this->exception_handler) {
                call_user_func($this->exception_handler, $exception, $request, $response);
            } else {
                throw $exception;
            }
        } catch (\Throwable $error) {
            if ($this->exception_handler) {
                call_user_func($this->exception_handler, $error, $request, $response);
            } else {
                throw $error;
            }
        }

        return $response;
    }
371128
private function setHttpResponse(OAuth2Response $response)
    {
        $httpResponse = $this->getResponse();
        $httpResponse->setStatusCode($response->getStatusCode());

        $headers = $httpResponse->getHeaders();
        $headers->addHeaders($response->getHttpHeaders());
        $headers->addHeaderLine('Content-type', 'application/json');

        $httpResponse->setContent($response->getResponseBody());
        return $httpResponse;
    }
887238
protected function httpGet($uri)
    {
        $results = [];
        // Start requesting at page 1
        $page = 1;
        // We dont know how many pages there are, so assume 1 until we know
        $pagecount = 1;
        while ($page <= $pagecount) {
            $this->log[] = [
                        'request' => [
                                    'method' => 'GET',
                                    'uri'    => $uri.'?page='.$page,
                                    ],
                        ];
            $response = \Httpful\Request::get($uri.'?page='.$page)
                                                    ->addHeader('X-Auth-Email', $this->email)
                                                    ->addHeader('X-Auth-Key', $this->apikey)
                                                    ->expectsType(\Httpful\Mime::JSON)
                                                    ->parseWith(function ($body) {
                                                        return \Metaclassing\Utility::decodeJson($body);
                                                    })
                                                    ->send()
                                                    ->body;
            $this->log[count($this->log) - 1]['response'] = $response;
            if ($response['success'] != true) {
                throw new \Exception("get {$uri} unsuccessful".\Metaclassing\Utility::encodeJson($response));
            }
            foreach ($response['result'] as $result) {
                array_push($results, $result);
            }
            // Now that we KNOW the pagecount, update that and increment our page counter
            $pagecount = $response['result_info']['total_pages'];
            // And get the next page ready for the next request
            $page++;
        }

        return $results;
    }