Skip to content

Commit ea1e231

Browse files
committed
fix Request test
2 parents 75cb6f5 + b22f03b commit ea1e231

File tree

2 files changed

+39
-7
lines changed

2 files changed

+39
-7
lines changed

src/Request.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ class Request extends PsrRequest implements ServerRequestInterface
7979
*/
8080
private $parsedBody;
8181

82+
/**
83+
* @var array
84+
*/
85+
private $parsedQuery = [];
86+
8287
/**
8388
* @var array
8489
*/
@@ -346,6 +351,27 @@ public function getParsedBody()
346351
return $this->parsedBody;
347352
}
348353

354+
/**
355+
* @return array
356+
*/
357+
public function getParsedQuery(): array
358+
{
359+
return $this->parsedQuery;
360+
}
361+
362+
/**
363+
* @param array $query
364+
*
365+
* @return Request
366+
*/
367+
public function withParsedQuery(array $query)
368+
{
369+
$clone = clone $this;
370+
371+
$clone->parsedQuery = $query;
372+
return $clone;
373+
}
374+
349375
/**
350376
* @param string $key
351377
* @param mixed|null $default

src/Response.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)