mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-03 04:08:01 +08:00
Adapte HEAD request
This commit is contained in:
parent
b5133f88fe
commit
67dd1ccb71
@ -37,7 +37,7 @@ class Response extends \Hyperf\HttpMessage\Base\Response implements Sendable
|
||||
/**
|
||||
* Handle response and send.
|
||||
*/
|
||||
public function send()
|
||||
public function send(bool $withContent = true)
|
||||
{
|
||||
if (! $this->getSwooleResponse()) {
|
||||
return;
|
||||
@ -48,7 +48,11 @@ class Response extends \Hyperf\HttpMessage\Base\Response implements Sendable
|
||||
if ($content instanceof FileInterface) {
|
||||
return $this->swooleResponse->sendfile($content->getFilename());
|
||||
}
|
||||
$this->swooleResponse->end($content->getContents());
|
||||
if ($withContent) {
|
||||
$this->swooleResponse->end($content->getContents());
|
||||
} else {
|
||||
$this->swooleResponse->end();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -117,7 +117,11 @@ class Server implements OnRequestInterface, MiddlewareInitializerInterface
|
||||
if (! isset($psr7Response) || ! $psr7Response instanceof Sendable) {
|
||||
return;
|
||||
}
|
||||
$psr7Response->send();
|
||||
if ($psr7Request->getMethod() === 'HEAD') {
|
||||
$psr7Response->send(false);
|
||||
} else {
|
||||
$psr7Response->send(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user