Get all headers as string
boolean $statusLine Whether to return the first status line (ie "HTTP 200 OK"):
string $br Line breaks (eg. "\n", "\r\n", "<br />"):
string
public function getHeadersAsString($statusLine = true, $br = "\n") {
$str = '';
if ($statusLine) {
$str = "HTTP/{$this->version} {$this->status} {$this->message}{$br}";
}
// Iterate over the headers and stringify them
foreach ($this->headers as $name => $value) {
if (is_string($value)) {
$str .= "{$name}: {$value}{$br}";
}
elseif (is_array($value)) {
foreach ($value as $subval) {
$str .= "{$name}: {$subval}{$br}";
}
}
}
return $str;
}