Beispiel #1
0
<?php

function dump($var)
{
    return highlight_string("<?php\n\$array = " . var_export($var, true) . ";", true);
}
$key_dir = dirname(dirname(__DIR__)) . '/tests/ssl';
$http = new swoole_http_server("0.0.0.0", 9501, SWOOLE_BASE);
//$http = new swoole_http_server("0.0.0.0", 9501);
//$http = new swoole_http_server("0.0.0.0", 9501, SWOOLE_BASE, SWOOLE_SOCK_TCP | SWOOLE_SSL);
//https
//$http = new swoole_http_server("0.0.0.0", 9501, SWOOLE_BASE, SWOOLE_SOCK_TCP | SWOOLE_SSL);
//$http->setGlobal(HTTP_GLOBAL_ALL, HTTP_GLOBAL_GET|HTTP_GLOBAL_POST|HTTP_GLOBAL_COOKIE);
$http->set([]);
$http->listen('127.0.0.1', 9502, SWOOLE_SOCK_TCP);
function chunk(swoole_http_request $request, swoole_http_response $response)
{
    $response->write("<h1>hello world1</h1>");
    //sleep(1);
    $response->write("<h1>hello world2</h1>");
    //sleep(1);
    $response->end();
}
function no_chunk(swoole_http_request $request, swoole_http_response $response)
{
    /**
     * Cookie Test
     */
    //$response->cookie('test1', '1234', time() + 86400, '/');
    //    $response->cookie('test2', '5678', time() + 86400);
    //    var_dump($response->cookie);