diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index 4cedff27eb56c..19f8f5e1e84f5 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -217,7 +217,7 @@ public function __construct(?string $content = '', int $status = 200, array $hea public function __toString(): string { return - $this->getCommandString()."\r\n". + sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText)."\r\n". $this->headers."\r\n". $this->getContent(); } @@ -230,14 +230,6 @@ public function __clone() $this->headers = clone $this->headers; } - /** - * @return string The first line of the actual HTTP request - */ - public function getCommandString(): string - { - return sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText); - } - /** * Prepares the Response before it is sent to the client. * diff --git a/src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseIsRedirected.php b/src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseIsRedirected.php index ba40e1b89c944..b1abd905e4248 100644 --- a/src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseIsRedirected.php +++ b/src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseIsRedirected.php @@ -49,7 +49,7 @@ protected function additionalFailureDescription($other): string if ($this->verbose || !($other instanceof Response)) { return (string) $other; } else { - return $other->getCommandString()."\r\n".$other->headers; + return explode("\r\n\r\n", (string) $other)[0]; } } } diff --git a/src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseIsSuccessful.php b/src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseIsSuccessful.php index fa675e6a1950a..d7d6c502a17cb 100644 --- a/src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseIsSuccessful.php +++ b/src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseIsSuccessful.php @@ -49,7 +49,7 @@ protected function additionalFailureDescription($other): string if ($this->verbose || !($other instanceof Response)) { return (string) $other; } else { - return $other->getCommandString()."\r\n".$other->headers; + return explode("\r\n\r\n", (string) $other)[0]; } } } diff --git a/src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseIsUnprocessable.php b/src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseIsUnprocessable.php index 7823aa78666c1..c791a31bd63cb 100644 --- a/src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseIsUnprocessable.php +++ b/src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseIsUnprocessable.php @@ -49,7 +49,7 @@ protected function additionalFailureDescription($other): string if ($this->verbose || !($other instanceof Response)) { return (string) $other; } else { - return $other->getCommandString()."\r\n".$other->headers; + return explode("\r\n\r\n", (string) $other)[0]; } } } diff --git a/src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseStatusCodeSame.php b/src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseStatusCodeSame.php index 458517293f5a4..8259e09fdf2f0 100644 --- a/src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseStatusCodeSame.php +++ b/src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseStatusCodeSame.php @@ -49,7 +49,7 @@ protected function additionalFailureDescription($other): string if ($this->verbose || !($other instanceof Response)) { return (string) $other; } else { - return $other->getCommandString()."\r\n".$other->headers; + return explode("\r\n\r\n", (string) $other)[0]; } } }