Lines Matching refs:server
163 struct php_cli_server *server; member
359 static const char *get_mime_type(const php_cli_server *server, const char *ext, size_t ext_len) /* … in get_mime_type() argument
361 return (const char*)zend_hash_str_find_ptr(&server->extension_mime_types, ext, ext_len); in get_mime_type()
627 …sapi_cli_server_register_variable(track_vars_array, "DOCUMENT_ROOT", client->server->document_root… in sapi_cli_server_register_variables()
654 sapi_cli_server_register_variable(track_vars_array, "SERVER_NAME", client->server->host); in sapi_cli_server_register_variables()
657 spprintf(&tmp, 0, "%i", client->server->port); in sapi_cli_server_register_variables()
667 } else if (client->server->router) { in sapi_cli_server_register_variables()
668 sapi_cli_server_register_variable(track_vars_array, "SCRIPT_FILENAME", client->server->router); in sapi_cli_server_register_variables()
1700 …_server_request_translate_vpath(&client->request, client->server->document_root, client->server->d… in php_cli_server_client_read_request_on_message_complete()
1836 static int php_cli_server_client_ctor(php_cli_server_client *client, php_cli_server *server, php_so… in php_cli_server_client_ctor() argument
1838 client->server = server; in php_cli_server_client_ctor()
1883 static void php_cli_server_close_connection(php_cli_server *server, php_cli_server_client *client) … in php_cli_server_close_connection() argument
1888 zend_hash_index_del(&server->clients, client->sock); in php_cli_server_close_connection()
1891 static int php_cli_server_send_error_page(php_cli_server *server, php_cli_server_client *client, in… in php_cli_server_send_error_page() argument
1971 php_cli_server_poller_add(&server->poller, POLLOUT, client->sock); in php_cli_server_send_error_page()
1986 static int php_cli_server_dispatch_script(php_cli_server *server, php_cli_server_client *client) /*… in php_cli_server_dispatch_script() argument
1990 return php_cli_server_send_error_page(server, client, 400); in php_cli_server_dispatch_script()
2008 static int php_cli_server_begin_send_static(php_cli_server *server, php_cli_server_client *client) … in php_cli_server_begin_send_static() argument
2015 return php_cli_server_send_error_page(server, client, 400); in php_cli_server_begin_send_static()
2027 return php_cli_server_send_error_page(server, client, 500); in php_cli_server_begin_send_static()
2033 return php_cli_server_send_error_page(server, client, 404); in php_cli_server_begin_send_static()
2043 const char *mime_type = get_mime_type(server, client->request.ext, client->request.ext_len); in php_cli_server_begin_send_static()
2074 php_cli_server_poller_add(&server->poller, POLLOUT, client->sock); in php_cli_server_begin_send_static()
2079 static int php_cli_server_request_startup(php_cli_server *server, php_cli_server_client *client) { … in php_cli_server_request_startup() argument
2097 static int php_cli_server_request_shutdown(php_cli_server *server, php_cli_server_client *client) {… in php_cli_server_request_shutdown() argument
2099 php_cli_server_close_connection(server, client); in php_cli_server_request_shutdown()
2107 static int php_cli_server_dispatch_router(php_cli_server *server, php_cli_server_client *client) /*… in php_cli_server_dispatch_router() argument
2113 zfd.filename = server->router; in php_cli_server_dispatch_router()
2136 static int php_cli_server_dispatch(php_cli_server *server, php_cli_server_client *client) /* {{{ */ in php_cli_server_dispatch() argument
2145 if (server->router || !is_static_file) { in php_cli_server_dispatch()
2146 if (FAILURE == php_cli_server_request_startup(server, client)) { in php_cli_server_dispatch()
2148 php_cli_server_close_connection(server, client); in php_cli_server_dispatch()
2154 if (server->router) { in php_cli_server_dispatch()
2155 if (!php_cli_server_dispatch_router(server, client)) { in php_cli_server_dispatch()
2156 php_cli_server_request_shutdown(server, client); in php_cli_server_dispatch()
2162 if (SUCCESS == php_cli_server_dispatch_script(server, client) in php_cli_server_dispatch()
2163 || SUCCESS != php_cli_server_send_error_page(server, client, 500)) { in php_cli_server_dispatch()
2167 php_cli_server_request_shutdown(server, client); in php_cli_server_dispatch()
2171 if (server->router) { in php_cli_server_dispatch()
2183 if (SUCCESS != php_cli_server_begin_send_static(server, client)) { in php_cli_server_dispatch()
2184 php_cli_server_close_connection(server, client); in php_cli_server_dispatch()
2196 static int php_cli_server_mime_type_ctor(php_cli_server *server, const php_cli_server_ext_mime_type… in php_cli_server_mime_type_ctor() argument
2200 zend_hash_init(&server->extension_mime_types, 0, NULL, NULL, 1); in php_cli_server_mime_type_ctor()
2204 zend_hash_str_add_ptr(&server->extension_mime_types, pair->ext, ext_len, (void*)pair->mime_type); in php_cli_server_mime_type_ctor()
2210 static void php_cli_server_dtor(php_cli_server *server) /* {{{ */ in php_cli_server_dtor() argument
2212 zend_hash_destroy(&server->clients); in php_cli_server_dtor()
2213 zend_hash_destroy(&server->extension_mime_types); in php_cli_server_dtor()
2214 if (ZEND_VALID_SOCKET(server->server_sock)) { in php_cli_server_dtor()
2215 closesocket(server->server_sock); in php_cli_server_dtor()
2217 if (server->host) { in php_cli_server_dtor()
2218 pefree(server->host, 1); in php_cli_server_dtor()
2220 if (server->document_root) { in php_cli_server_dtor()
2221 pefree(server->document_root, 1); in php_cli_server_dtor()
2223 if (server->router) { in php_cli_server_dtor()
2224 pefree(server->router, 1); in php_cli_server_dtor()
2233 php_cli_server_poller_remove(&p->server->poller, POLLIN | POLLOUT, p->sock); in php_cli_server_client_dtor_wrapper()
2238 static int php_cli_server_ctor(php_cli_server *server, const char *addr, const char *document_root,… in php_cli_server_ctor() argument
2287 …server_sock = php_network_listen_socket(host, &port, SOCK_STREAM, &server->address_family, &server… in php_cli_server_ctor()
2296 server->server_sock = server_sock; in php_cli_server_ctor()
2298 err = php_cli_server_poller_ctor(&server->poller); in php_cli_server_ctor()
2303 php_cli_server_poller_add(&server->poller, POLLIN, server_sock); in php_cli_server_ctor()
2305 server->host = host; in php_cli_server_ctor()
2306 server->port = port; in php_cli_server_ctor()
2308 zend_hash_init(&server->clients, 0, NULL, php_cli_server_client_dtor_wrapper, 1); in php_cli_server_ctor()
2317 server->document_root = _document_root; in php_cli_server_ctor()
2318 server->document_root_len = document_root_len; in php_cli_server_ctor()
2324 _router = pemalloc(server->document_root_len + router_len + 2, 1); in php_cli_server_ctor()
2330 …server->document_root_len + router_len + 2, "%s%c%s", server->document_root, DEFAULT_SLASH, router… in php_cli_server_ctor()
2338 server->router = _router; in php_cli_server_ctor()
2339 server->router_len = router_len; in php_cli_server_ctor()
2341 server->router = NULL; in php_cli_server_ctor()
2342 server->router_len = 0; in php_cli_server_ctor()
2345 if (php_cli_server_mime_type_ctor(server, mime_type_map) == FAILURE) { in php_cli_server_ctor()
2350 server->is_running = 1; in php_cli_server_ctor()
2369 static int php_cli_server_recv_event_read_request(php_cli_server *server, php_cli_server_client *cl… in php_cli_server_recv_event_read_request() argument
2382 php_cli_server_close_connection(server, client); in php_cli_server_recv_event_read_request()
2385 return php_cli_server_send_error_page(server, client, 501); in php_cli_server_recv_event_read_request()
2387 php_cli_server_poller_remove(&server->poller, POLLIN, client->sock); in php_cli_server_recv_event_read_request()
2388 php_cli_server_dispatch(server, client); in php_cli_server_recv_event_read_request()
2390 php_cli_server_poller_add(&server->poller, POLLIN, client->sock); in php_cli_server_recv_event_read_request()
2396 static int php_cli_server_send_event(php_cli_server *server, php_cli_server_client *client) /* {{{ … in php_cli_server_send_event() argument
2402 php_cli_server_close_connection(server, client); in php_cli_server_send_event()
2414 php_cli_server_close_connection(server, client); in php_cli_server_send_event()
2419 php_cli_server_close_connection(server, client); in php_cli_server_send_event()
2427 php_cli_server *server; member
2435 php_cli_server *server = params->server; in php_cli_server_do_event_for_each_fd_callback() local
2436 if (server->server_sock == fd) { in php_cli_server_do_event_for_each_fd_callback()
2439 socklen_t socklen = server->socklen; in php_cli_server_do_event_for_each_fd_callback()
2440 struct sockaddr *sa = pemalloc(server->socklen, 1); in php_cli_server_do_event_for_each_fd_callback()
2444 client_sock = accept(server->server_sock, sa, &socklen); in php_cli_server_do_event_for_each_fd_callback()
2458 …cli_server_client), 1)) || FAILURE == php_cli_server_client_ctor(client, server, client_sock, sa, … in php_cli_server_do_event_for_each_fd_callback()
2467 zend_hash_index_update_ptr(&server->clients, client_sock, client); in php_cli_server_do_event_for_each_fd_callback()
2468 php_cli_server_recv_event_read_request(server, client); in php_cli_server_do_event_for_each_fd_callback()
2471 if (NULL != (client = zend_hash_index_find_ptr(&server->clients, fd))) { in php_cli_server_do_event_for_each_fd_callback()
2473 params->rhandler(server, client); in php_cli_server_do_event_for_each_fd_callback()
2476 params->whandler(server, client); in php_cli_server_do_event_for_each_fd_callback()
2483 static void php_cli_server_do_event_for_each_fd(php_cli_server *server, int(*rhandler)(php_cli_serv… in php_cli_server_do_event_for_each_fd() argument
2486 server, in php_cli_server_do_event_for_each_fd()
2491 …php_cli_server_poller_iter_on_active(&server->poller, ¶ms, php_cli_server_do_event_for_each_fd… in php_cli_server_do_event_for_each_fd()
2494 static int php_cli_server_do_event_loop(php_cli_server *server) /* {{{ */ in php_cli_server_do_event_loop() argument
2497 while (server->is_running) { in php_cli_server_do_event_loop()
2499 int n = php_cli_server_poller_poll(&server->poller, &tv); in php_cli_server_do_event_loop()
2501 php_cli_server_do_event_for_each_fd(server, in php_cli_server_do_event_loop()
2521 static php_cli_server server; variable
2525 server.is_running = 0; in php_cli_server_sigint_handler()
2580 if (FAILURE == php_cli_server_ctor(&server, server_bind_address, document_root, router)) { in do_cli_server()
2602 php_cli_server_do_event_loop(&server); in do_cli_server()
2603 php_cli_server_dtor(&server); in do_cli_server()