
SwooleHttpResponse::write 함수는 HTTP 헤더와 본문을 분리하여 전송해야 합니다.
이 함수는 HTTP 헤더를 설정하기 위해 사용할 수 있으며, 헤더를 설정한 후에 SwooleHttpResponse::end 함수를 호출하여 HTTP 본문을 전송해야 합니다.
예를 들어, 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
php
$http = new SwooleHttpServer(...);
$http->on('request', function ($request, $response) {
$response->status(200);
$response->header('Content-Type', 'text/plain');
$response->write('HTTP 헤더');
$response->end('HTTP 본문');
});
이 예제에서는 HTTP 헤더를 설정하고 write 함수를 사용하여 헤더를 전송한 후, end 함수를 호출하여 HTTP 본문을 전송합니다.
2025-03-26 13:04