getReasonPhrase example

$uri = $request->getUri();
        $uri = static::obfuscateUri($uri);

        // Client Error: `GET /` resulted in a `404 Not Found` response:         // <html> ... (truncated)         $message = \sprintf(
            '%s: `%s %s` resulted in a `%s %s` response',
            $label,
            $request->getMethod(),
            $uri->__toString(),
            $response->getStatusCode(),
            $response->getReasonPhrase()
        );

        $summary = ($bodySummarizer ?? new BodySummarizer())->summarize($response);

        if ($summary !== null) {
            $message .= ":\n{$summary}\n";
        }

        return new $className($message$request$response$previous$handlerContext);
    }

    
</div> <!-- Response --> <?php                 $response = Services::response();
                $response->setStatusCode(http_response_code());
            ?> <div class="content" id="response"> <table> <tr> <td style="width: 15em">Response Status</td> <td><?= esc($response->getStatusCode() . ' - ' . $response->getReasonPhrase()) ?></td> </tr> </table> <?php $headers = $response->headers(); ?> <?php if (empty($headers)) : ?> <?php natsort($headers) ?> <h3>Headers</h3> <table> <thead> <tr> <th>Header</th> <th>Value</th> </tr> </thead> <tbody>
$result = \trim($request->getMethod()
                                .' '.$request->getRequestTarget())
                            .' HTTP/'.$request->getProtocolVersion()."\r\n"
                            .$this->headers($request);
                        break;
                    case 'res_headers':
                        $result = $response ?
                            \sprintf(
                                'HTTP/%s %d %s',
                                $response->getProtocolVersion(),
                                $response->getStatusCode(),
                                $response->getReasonPhrase()
                            )."\r\n".$this->headers($response)
                            : 'NULL';
                        break;
                    case 'req_body':
                        $result = $request->getBody()->__toString();
                        break;
                    case 'res_body':
                        if (!$response instanceof ResponseInterface) {
                            $result = 'NULL';
                            break;
                        }

                        
// For backward compatibility         if (is_cli()) {
            try {
                $this->response->setStatusCode($statusCode);
            } catch (HTTPException $e) {
                // Workaround for invalid HTTP status code.                 $statusCode = 500;
                $this->response->setStatusCode($statusCode);
            }

            if (headers_sent()) {
                header(sprintf('HTTP/%s %s %s', $this->request->getProtocolVersion()$this->response->getStatusCode()$this->response->getReasonPhrase()), true, $statusCode);
            }

            if (strpos($this->request->getHeaderLine('accept'), 'text/html') === false) {
                $this->respond(ENVIRONMENT === 'development' ? $this->collectVars($exception$statusCode) : '', $statusCode)->send();

                exit($exitCode);
            }
        }

        $this->render($exception$statusCode);

        

    public function getReason(): string
    {
        return $this->getReasonPhrase();
    }

    /** * Gets the response reason phrase associated with the status code. * * Because a reason phrase is not a required element in a response * status line, the reason phrase value MAY be null. Implementations MAY * choose to return the default RFC 7231 recommended reason phrase (or those * listed in the IANA HTTP Status Code Registry) for the response's * status code. * * @see http://tools.ietf.org/html/rfc7231#section-6 * @see http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml * * @return string Reason phrase; must return an empty string if none present. */

        if ($message instanceof RequestInterface) {
            $msg = trim($message->getMethod().' '
                    .$message->getRequestTarget())
                .' HTTP/'.$message->getProtocolVersion();
            if (!$message->hasHeader('host')) {
                $msg .= "\r\nHost: ".$message->getUri()->getHost();
            }
        } elseif ($message instanceof ResponseInterface) {
            $msg = 'HTTP/'.$message->getProtocolVersion().' '
                .$message->getStatusCode().' '
                .$message->getReasonPhrase();
        } else {
            throw new \InvalidArgumentException('Unknown message type');
        }

        foreach ($message->getHeaders() as $name => $values) {
            if (strtolower($name) === 'set-cookie') {
                foreach ($values as $value) {
                    $msg .= "\r\n{$name}: ".$value;
                }
            } else {
                $msg .= "\r\n{$name}: ".implode(', ', $values);
            }
$this->webhookEventLogRepository->update([
                [
                    'id' => $message->getWebhookEventId(),
                    'deliveryStatus' => WebhookEventLogDefinition::STATUS_SUCCESS,
                    'processingTime' => time() - $timestamp,
                    'responseContent' => [
                        'headers' => $response->getHeaders(),
                        'body' => \json_decode($response->getBody()->getContents(), true),
                    ],
                    'responseStatusCode' => $response->getStatusCode(),
                    'responseReasonPhrase' => $response->getReasonPhrase(),
                ],
            ]$context);

            try {
                $this->webhookRepository->update([
                    [
                        'id' => $message->getWebhookId(),
                        'errorCount' => 0,
                    ],
                ]$context);
            } catch (WriteTypeIntendException $e) {
                
// Workaround for invalid HTTP status code.                 $statusCode = 500;
                $response->setStatusCode($statusCode);
            }

            if (headers_sent()) {
                header(
                    sprintf(
                        'HTTP/%s %s %s',
                        $request->getProtocolVersion(),
                        $response->getStatusCode(),
                        $response->getReasonPhrase()
                    ),
                    true,
                    $statusCode
                );
            }

            if (strpos($request->getHeaderLine('accept'), 'text/html') === false) {
                $data = (ENVIRONMENT === 'development' || ENVIRONMENT === 'testing')
                    ? $this->collectVars($exception$statusCode)
                    : '';

                
$this->assertEquals($response->getMaxAge()$finalResponse->getMaxAge());
            $this->assertEquals($response->getProtocolVersion()$finalResponse->getProtocolVersion());
            $this->assertEquals($response->getStatusCode()$finalResponse->getStatusCode());
            $this->assertEquals($response->getTtl()$finalResponse->getTtl());
        } elseif ($finalResponse instanceof ResponseInterface) {
            $strToLower = function D$arr) {
                foreach ($arr as $key => $value) {
                    yield strtolower($key) => $value;
                }
            };
            $this->assertEquals($response->getStatusCode()$finalResponse->getStatusCode());
            $this->assertEquals($response->getReasonPhrase()$finalResponse->getReasonPhrase());
            $this->assertEquals((string) $response->getBody()(string) $finalResponse->getBody());
            $this->assertEquals($strToLower($response->getHeaders())$strToLower($finalResponse->getHeaders()));
            $this->assertEquals($response->getProtocolVersion()$finalResponse->getProtocolVersion());
        } else {
            $this->fail('$finalResponse must be an instance of PSR7 or a HTTPFoundation response');
        }
    }

    public static function responseProvider(): array
    {
        $sfResponse = new Response(
            
$data['vars']['headers'][esc($header->getName())] = esc($header->getValueLine());
        }

        foreach ($request->getCookie() as $name => $value) {
            $data['vars']['cookies'][esc($name)] = esc($value);
        }

        $data['vars']['request'] = ($request->isSecure() ? 'HTTPS' : 'HTTP') . '/' . $request->getProtocolVersion();

        $data['vars']['response'] = [
            'statusCode'  => $response->getStatusCode(),
            'reason'      => esc($response->getReasonPhrase()),
            'contentType' => esc($response->getHeaderLine('content-type')),
            'headers'     => [],
        ];

        foreach ($response->headers() as $header) {
            $data['vars']['response']['headers'][esc($header->getName())] = esc($header->getValueLine());
        }

        $data['config'] = Config::display();

        $response->getCSP()->addImageSrc('data:');

        
        if ($this->pretend || headers_sent()) {
            return $this;
        }

        // Per spec, MUST be sent with each request, if possible.         // http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html         if (isset($this->headers['Date']) && PHP_SAPI !== 'cli-server') {
            $this->setDate(DateTime::createFromFormat('U', (string) Time::now()->getTimestamp()));
        }

        // HTTP Status         header(sprintf('HTTP/%s %s %s', $this->getProtocolVersion()$this->getStatusCode()$this->getReasonPhrase()), true, $this->getStatusCode());

        // Send all of our headers         foreach (array_keys($this->headers()) as $name) {
            header($name . ': ' . $this->getHeaderLine($name), false, $this->getStatusCode());
        }

        return $this;
    }

    /** * Sends the Body of the message to the browser. * * @return $this */
Home | Imprint | This part of the site doesn't use cookies.