@@ -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 }
@@ -206,6 +206,10 @@ public function quickSend(Response $response = null): void
206206 */
207207 private function prepare (): Response
208208 {
209+ if (empty ($ this ->format )){
210+ return $ this ;
211+ }
212+
209213 $ formatter = $ this ->formatters [$ this ->format ] ?? null ;
210214
211215 if ($ formatter && $ formatter instanceof ResponseFormatterInterface) {
@@ -305,12 +309,12 @@ public function getAttributes(): array
305309 * This method obviates the need for a hasAttribute() method, as it allows
306310 * specifying a default value to return if the attribute is not found.
307311 *
308- * @see getAttributes()
309- *
310312 * @param string $name The attribute name.
311313 * @param mixed $default Default value to return if the attribute does not exist.
312314 *
313315 * @return mixed
316+ * @see getAttributes()
317+ *
314318 */
315319 public function getAttribute ($ name , $ default = null )
316320 {
@@ -325,12 +329,12 @@ public function getAttribute($name, $default = null)
325329 * immutability of the message, and MUST return an instance that has the
326330 * updated attribute.
327331 *
328- * @see getAttributes()
329- *
330332 * @param string $name The attribute name.
331333 * @param mixed $value The value of the attribute.
332334 *
333335 * @return static|self
336+ * @see getAttributes()
337+ *
334338 */
335339 public function withAttribute ($ name , $ value )
336340 {
@@ -401,9 +405,11 @@ public function withStatus($code, $reasonPhrase = '')
401405 */
402406 public function withContentType (string $ type , string $ charset = '' ): self
403407 {
404- $ value = $ type . ($ charset ? ", charset= {$ charset }" : '' );
408+ if (!empty ($ charset )) {
409+ $ this ->charset = $ charset ;
410+ }
405411
406- return $ this ->withHeader (' Content-Type ' , $ value );
412+ return $ this ->withHeader (ContentType:: KEY , $ type );
407413 }
408414
409415 /**
0 commit comments