Exemplo n.º 1
0
function test_callback($evhttp_request)
{
    echo "script-land memory: " . memory_get_usage() . " and real memory from system: " . memory_get_usage(true) . "\n";
    $uri = evhttp_request_uri($evhttp_request);
    $ct = evhttp_request_find_header($evhttp_request, 'Content-Type');
    echo "URI: {$uri}\n";
    echo "Content-Type: {$ct}\n";
    print_r(evhttp_request_headers($evhttp_request));
    echo evhttp_request_body($evhttp_request);
    evhttp_response_add_header($evhttp_request, "Content-Type", "text/plain");
    return evhttp_response_set("Hello World!", 200, "OK");
}
Exemplo n.º 2
0
 private function _initRequest($r)
 {
     $_SERVER["REQUEST_METHOD"] = evhttp_request_method($r);
     $_SERVER["REQUEST_TIME"] = time();
     $_SERVER["argv"] = $_SERVER["REQUEST_URI"] = evhttp_request_get_uri($r);
     $parts = parse_url($_SERVER["REQUEST_URI"]);
     $_SERVER['QUERY_STRING'] = $parts['query'];
     parse_str($_SERVER['QUERY_STRING'], $_GET);
     $headers = evhttp_request_headers($r);
     // normalize to php way
     foreach ($headers as $name => $value) {
         $_SERVER["HTTP_" . str_replace("-", "_", strtoupper($name))] = $value;
     }
     echo "script-land memory: " . memory_get_usage() . "\n";
 }