@@ -163,7 +163,7 @@ public function send(): void
163163 {
164164 // Is send file
165165 if ($ this ->filePath ) {
166- $ this ->coResponse ->header (' Content-Type ' , $ this ->fileType );
166+ $ this ->coResponse ->header (ContentType:: KEY , $ this ->fileType );
167167 $ this ->coResponse ->sendfile ($ this ->filePath );
168168 return ;
169169 }
@@ -211,6 +211,10 @@ public function quickSend(Response $response = null): void
211211 */
212212 private function prepare (): Response
213213 {
214+ if (empty ($ this ->format )){
215+ return $ this ;
216+ }
217+
214218 $ formatter = $ this ->formatters [$ this ->format ] ?? null ;
215219
216220 if ($ formatter && $ formatter instanceof ResponseFormatterInterface) {
@@ -310,12 +314,12 @@ public function getAttributes(): array
310314 * This method obviates the need for a hasAttribute() method, as it allows
311315 * specifying a default value to return if the attribute is not found.
312316 *
313- * @see getAttributes()
314- *
315317 * @param string $name The attribute name.
316318 * @param mixed $default Default value to return if the attribute does not exist.
317319 *
318320 * @return mixed
321+ * @see getAttributes()
322+ *
319323 */
320324 public function getAttribute ($ name , $ default = null )
321325 {
@@ -330,12 +334,12 @@ public function getAttribute($name, $default = null)
330334 * immutability of the message, and MUST return an instance that has the
331335 * updated attribute.
332336 *
333- * @see getAttributes()
334- *
335337 * @param string $name The attribute name.
336338 * @param mixed $value The value of the attribute.
337339 *
338340 * @return static|self
341+ * @see getAttributes()
342+ *
339343 */
340344 public function withAttribute ($ name , $ value )
341345 {
@@ -406,9 +410,11 @@ public function withStatus($code, $reasonPhrase = '')
406410 */
407411 public function withContentType (string $ type , string $ charset = '' ): self
408412 {
409- $ value = $ type . ($ charset ? ", charset= {$ charset }" : '' );
413+ if (!empty ($ charset )) {
414+ $ this ->charset = $ charset ;
415+ }
410416
411- return $ this ->withHeader (' Content-Type ' , $ value );
417+ return $ this ->withHeader (ContentType:: KEY , $ type );
412418 }
413419
414420 /**
0 commit comments