
SwooleHttpResponse::end 메서드는 HTTP 응답 바디에 데이터를 추가할 수 있습니다.
end 메서드를 여러 번 호출하면, 이전에 추가된 데이터는 모두 제거되고, 새로운 데이터만 추가됩니다.
end 메서드를 호출하지 않고 close 메서드를 호출하면, HTTP 응답이 즉시 종료되고, 데이터가 전송되지 않습니다.
따라서, HTTP 응답 바디에 데이터를 추가하고 싶은 경우에는 end 메서드를 호출해야 합니다.
만약에 close 메서드를 호출하고 싶은 경우에는 end 메서드를 호출한 후 close 메서드를 호출하면 됩니다.
예를 들어, 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
php
$http = new SwooleHttpServer(...);
$http->on('request', function ($request, $response) {
$response->end('Hello, World!');
});
$http->start();
또는
#hostingforum.kr
php
$http = new SwooleHttpServer(...);
$http->on('request', function ($request, $response) {
$response->end('Hello, ');
$response->end('World!');
});
$http->start();
또는
#hostingforum.kr
php
$http = new SwooleHttpServer(...);
$http->on('request', function ($request, $response) {
$response->end('Hello, World!');
$response->close();
});
$http->start();
2025-03-27 05:15