Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7d0265c

Browse files
committed
Build response header manually
1 parent 0b4a584 commit 7d0265c

File tree

5 files changed

+5
-13
lines changed

5 files changed

+5
-13
lines changed

src/Symfony/Component/HttpFoundation/Response.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public function __construct(?string $content = '', int $status = 200, array $hea
217217
public function __toString(): string
218218
{
219219
return
220-
$this->getCommandString()."\r\n".
220+
sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText)."\r\n".
221221
$this->headers."\r\n".
222222
$this->getContent();
223223
}
@@ -230,14 +230,6 @@ public function __clone()
230230
$this->headers = clone $this->headers;
231231
}
232232

233-
/**
234-
* @return string The first line of the actual HTTP request
235-
*/
236-
public function getCommandString(): string
237-
{
238-
return sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText);
239-
}
240-
241233
/**
242234
* Prepares the Response before it is sent to the client.
243235
*

src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseIsRedirected.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected function additionalFailureDescription($other): string
4949
if ($this->verbose || !($other instanceof Response)) {
5050
return (string) $other;
5151
} else {
52-
return $other->getCommandString()."\r\n".$other->headers;
52+
return explode("\r\n\r\n", (string) $other)[0];
5353
}
5454
}
5555
}

src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseIsSuccessful.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected function additionalFailureDescription($other): string
4949
if ($this->verbose || !($other instanceof Response)) {
5050
return (string) $other;
5151
} else {
52-
return $other->getCommandString()."\r\n".$other->headers;
52+
return explode("\r\n\r\n", (string) $other)[0];
5353
}
5454
}
5555
}

src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseIsUnprocessable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected function additionalFailureDescription($other): string
4949
if ($this->verbose || !($other instanceof Response)) {
5050
return (string) $other;
5151
} else {
52-
return $other->getCommandString()."\r\n".$other->headers;
52+
return explode("\r\n\r\n", (string) $other)[0];
5353
}
5454
}
5555
}

src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseStatusCodeSame.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected function additionalFailureDescription($other): string
4949
if ($this->verbose || !($other instanceof Response)) {
5050
return (string) $other;
5151
} else {
52-
return $other->getCommandString()."\r\n".$other->headers;
52+
return explode("\r\n\r\n", (string) $other)[0];
5353
}
5454
}
5555
}

0 commit comments

Comments
 (0)