public function testMessageWithNoHeaders() { $body = "\n<html>...</html>\n"; $message = "\r\n\r\n{$body}"; $response = new Response(compact('message')); $this->assertEmpty($response->headers()); $this->assertEqual(trim($body), $response->body()); }
/** * Expands on `\net\http\Message::headers()` with some magic conversions for shorthand headers. * * @deprecated This method will be removed in a future version. Note that the parent `header()` * wil continue to exist. * @param string|array $key * @param mixed $value * @param boolean $replace * @return mixed */ public function headers($key = null, $value = null, $replace = true) { if ($key === 'download' || $key === 'Download') { $message = "Shorthand header `Download` with `<FILENAME>` has been deprecated "; $message .= "because it's too magic. Please use `Content-Disposition` "; $message .= "with `attachment; filename=\"<FILENAME>\"` instead."; trigger_error($message, E_USER_DEPRECATED); $key = 'Content-Disposition'; $value = 'attachment; filename="' . $value . '"'; } return parent::headers($key, $value, $replace); }
/** * Expands on `\net\http\Message::headers()` with some magic conversions for shorthand headers. * * @param string $key * @param string $value * @param boolean $replace * @return mixed */ public function headers($key = null, $value = null, $replace = true) { if (is_string($key) && strtolower($key) == 'download') { $key = 'Content-Disposition'; $value = 'attachment; filename="' . $value . '"'; } return parent::headers($key, $value, $replace); }