本文整理汇总了PHP中HttpResponse::writeContent方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpResponse::writeContent方法的具体用法?PHP HttpResponse::writeContent怎么用?PHP HttpResponse::writeContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpResponse
的用法示例。
在下文中一共展示了HttpResponse::writeContent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: threadmain
function threadmain()
{
// Read request block
$buf = "";
while (true) {
$rl = socket_read($this->sock, 4096, PHP_BINARY_READ);
if (false == $rl) {
socket_close($this->sock);
return;
} else {
$buf = $buf . $rl;
}
if (strpos($buf, "\r\n\r\n")) {
break;
} else {
console::writeLn('%s', $buf);
}
}
$db = explode("\r\n\r\n", $buf);
$data = $db[0];
// Put back the rest of the buffer for posts etc
$buf = join('', array_slice($db, 1));
$request = new HttpRequest($data);
// data
$response = new HttpResponse();
// Pop the header off the buffer
$status = call_user_func_array($this->handler, array(&$request, &$response));
if ($status == 0) {
$status = 200;
}
$peer = "";
$port = 0;
socket_getpeername($this->sock, $peer, $port);
console::writeLn("%s %s:%d %d %s", $request->getMethod(), $peer, $port, $status, $request->getUri());
$response->writeHeaders($this->sock, 200);
$response->writeContent($this->sock);
socket_shutdown($this->sock, 2);
usleep(50000);
socket_close($this->sock);
}