Gets the content for the response

@param Throwable|Exception $ex The exception
@param int $statusCode The HTTP status code
@param array $headers The HTTP headers
@return string The response content
350446
protected function getResponseContent($ex, int $statusCode, array $headers) : string
    {
        return $this->getDefaultResponseContent($ex, $statusCode);
    }
870315
protected function getResponse(array $headers, $body)
	{
		// Create the response object.
		$return = new Response;

		// Set the body for the response.
		$return->body = $body;

		// Get the response code from the first offset of the response headers.
		preg_match('/[0-9]{3}/', array_shift($headers), $matches);
		$code = $matches[0];

		if (is_numeric($code))
		{
			$return->code = (int) $code;
		}

		// No valid response code was detected.
		else
		{
			throw new \UnexpectedValueException('No HTTP response code found.');
		}

		// Add the response headers to the response object.
		foreach ($headers as $header)
		{
			$pos = strpos($header, ':');
			$return->headers[trim(substr($header, 0, $pos))] = trim(substr($header, ($pos + 1)));
		}

		return $return;
	}
1096033
private function getDebugTraceResponse(\Exception $exception, $statusCode)
    {
        $request = $this->application->getRequest();
        $response = (new \Symfony\Component\Debug\ExceptionHandler())->createResponse($exception);
        $response->setStatusCode($statusCode);

        if (in_array('application/json', $request->getAcceptableContentTypes())) {
            $response = new JsonResponse($response->getContent(), $response->getStatusCode(), $response->headers->all());
        }

        return $response;
    }
598675
protected function getExceptionCode()
    {
        $exception = $this->getException();

        if ($exception instanceof HttpException) {
            return $exception->statusCode;
        }

        return $exception->getCode();
    }
626710
public function response($content, int $statusCode = 200, string $statusMessage = 'OK'): Response
    {
        $response = [
            'statusCode' => $statusCode,
            'statusMessage' => $statusMessage,
            'content' => $content,
        ];

        if ($this->config->application->debug->logRequest) {
            $this->log->addInfo('RESPONSE', $response);
        }

        // Create a response since it's an ajax
        //in order to use the current response instead of having to create a new object , this is needed for swoole servers
        $response = $this->response ?? new Response(); 
        $response->setStatusCode($statusCode, $statusMessage);
        $response->setContentType('application/vnd.api+json', 'UTF-8');
        $response->setJsonContent($content);

        return $response;
    }
128203
public static function assertJsonResponse(Response $response, $statusCode = 200)
    {
        \PHPUnit\Framework\Assert::assertEquals(
            $statusCode,
            $response->getStatusCode(),
            $response->getContent()
        );
        \PHPUnit\Framework\Assert::assertTrue(
            $response->headers->contains('Content-Type', 'application/json'),
            $response->headers
        );
    }
702222
protected function getMetaResponse($meta, $statusCode = Response::HTTP_OK)
    {
        $this->checkParameters();

        /** @var ResponsesInterface $responses */
        $responses       = $this->getIntegration()->getFromContainer(ResponsesInterface::class);
        $encoder         = $this->codecMatcher->getEncoder();
        $outputMediaType = $this->codecMatcher->getEncoderRegisteredMatchedType();
        $content         = $encoder->encodeMeta($meta);

        return $responses->getResponse($statusCode, $outputMediaType, $content, $this->supportedExtensions);
    }
134103
public function json($data, $code = 200, array $headers = [])
    {
        $this->addHeader('Content-Type', 'application/json; charset=UTF-8');

        foreach ($headers as $key => $value) {
            $this->addHeader($key, $value);
        }

        $this->content = json_encode($data);

        $this->code = $code;

        return $this->buildHttpResponse();
    }
372774
public function respond($response, $status, $headers, $options)
    {
        switch ($this->getRequestFormat()) {
            case 'html' :
            case 'text/html' :
                return Response::make($response, $status, $headers, $options)
                    ->header('Content-Type', 'text/html');
            default :
                // whether 'Content-Type' is NULL or equal to anything such as 'application/json' response will be JSON
                return Response::json($response, $status, $headers, $options);
        }
    }
558120
public function splitResponseHeaderAndBody(string $response, int $statusCode)
    {
        $headers = [];

        $split = strpos($response, "\r\n\r\n");
        $header = substr($response, 0, $split);
        $body = str_replace($header."\r\n\r\n", '', $response);

        foreach (explode("\r\n", $header) as $i => $strLine) {
            if (0 === $i) {
                $headers['http_code'] = $statusCode;
            } else {
                list($strKey, $varValue) = explode(': ', $strLine);
                $headers[$strKey] = $varValue;
            }
        }

        return [$headers, trim($body)];
    }
692845
protected function responseError($body, $httpCode)
    {
        return $this->parseResponse($body) ?: $this->jsonError($body, $httpCode);
    }
975838
public function response($content, $statusCode = 200)
    {
        return response()
            ->json($this->convertContent($content))
            ->setStatusCode($statusCode);
    }
568914
private function _extractHttpStatusCode($headers){
    	$statusCode = null; 
        if (1 === preg_match("/(\\S+) +(\\d+) +([^\n\r]+)(?:\r?\n|\r)/", $headers, $matches)) {
        	//The matches array [entireMatchString, protocol, statusCode, the rest]
            $statusCode = $matches[2]; 
        }
        return $statusCode;
    }
725841
public static function json($data, $status = 200, $headers = array())
    {
        $jsonHeader = array('Content-Type' => 'application/json');

        $content = json_encode($data);

        return new Response($content, $status, $jsonHeader);
    }
710316
public static function createFromArray($statusCode, array $data = [])
    {
        $response = new static($statusCode);

        if (isset($data['body']) && \is_array($data['body'])) {
            foreach ($data['body'] as $key => $bodyData) {
                $response->addBody(Body::createFromArray($key, $bodyData ?: []));
            }
        }

        if (isset($data['description'])) {
            $response->setDescription($data['description']);
        }

        if (isset($data['headers'])) {
            foreach ($data['headers'] as $key => $header) {
                $response->addHeader(NamedParameter::createFromArray($key, $header));
            }
        }

        return $response;
    }
1236282
protected function makeResponse(int $status, $content, ?\Throwable $e = null): ResponseInterface
    {
        $exceptionMarker = (2 != intval($status / 100));

        if ($exceptionMarker && Core::env('TESTING')) {

            $logData = [$content, $status];
            is_null($e) ?: $logData[] = $e->getTraceAsString();
            Core::get('Logger')->info($logData);

            if (!is_array($content)) {
                $content = ['message' => $content];
            }

            return new JsonResponse($content, $status);
        }

        if($exceptionMarker) {
            $content = [];

        } elseif (!is_array($content)) {
            if (is_object($content)) {
                $content = get_object_vars($content);
            } else {
                $content = ['data' => $content];
            }
        }

        return new JsonResponse($content, $status);
    }
225324
private function getErrorPageResponse(\Exception $exception, $statusCode)
    {
        $parameter = $this->application->getContainer()->getParameter('error.default');
        if ($this->application->getContainer()->hasParameter('error.'.$statusCode)) {
            $parameter = $this->application->getContainer()->getParameter('error.'.$statusCode);
        }

        $view = $this->getErrorTemplate($parameter);

        return new Response($this->renderer->partial($view, ['error' => $exception]), $statusCode);
    }