Lines Matching refs:client
231 static size_t php_cli_server_client_send_through(php_cli_server_client *client, const char *str, si…
235 static void php_cli_server_log_response(php_cli_server_client *client, int status, const char *mess…
359 static void append_essential_headers(smart_str* buffer, php_cli_server_client *client, bool persist… in append_essential_headers() argument
379 if (NULL != (val = zend_hash_find(&client->request.headers, ZSTR_KNOWN(ZEND_STR_HOST)))) { in append_essential_headers()
409 php_cli_server_client *client; in PHP_FUNCTION() local
415 client = SG(server_context); in PHP_FUNCTION()
418 RETURN_ARR(zend_array_dup(&client->request.headers_original_case)); in PHP_FUNCTION()
520 php_cli_server_client *client = SG(server_context); in sapi_cli_server_ub_write() local
521 if (!client) { in sapi_cli_server_ub_write()
524 return php_cli_server_client_send_through(client, str, str_length); in sapi_cli_server_ub_write()
529 php_cli_server_client *client = server_context; in sapi_cli_server_flush() local
531 if (!client) { in sapi_cli_server_flush()
535 if (!ZEND_VALID_SOCKET(client->sock)) { in sapi_cli_server_flush()
553 php_cli_server_client *client = SG(server_context); in sapi_cli_server_send_headers() local
558 if (client == NULL || SG(request_info).no_headers) { in sapi_cli_server_send_headers()
566 …append_http_status_line(&buffer, client->request.protocol_version, SG(sapi_headers).http_response_… in sapi_cli_server_send_headers()
569 append_essential_headers(&buffer, client, 0, sapi_headers); in sapi_cli_server_send_headers()
581 php_cli_server_client_send_through(client, ZSTR_VAL(buffer.s), ZSTR_LEN(buffer.s)); in sapi_cli_server_send_headers()
590 php_cli_server_client *client = SG(server_context); in sapi_cli_server_read_cookies() local
592 if (NULL == (val = zend_hash_str_find(&client->request.headers, "cookie", sizeof("cookie")-1))) { in sapi_cli_server_read_cookies()
600 php_cli_server_client *client = SG(server_context); in sapi_cli_server_read_post() local
601 if (client->request.content) { in sapi_cli_server_read_post()
602 size_t content_len = client->request.content_len; in sapi_cli_server_read_post()
603 …size_t nbytes_copied = MIN(client->post_read_offset + count_bytes, content_len) - client->post_rea… in sapi_cli_server_read_post()
604 memmove(buf, client->request.content + client->post_read_offset, nbytes_copied); in sapi_cli_server_read_post()
605 client->post_read_offset += nbytes_copied; in sapi_cli_server_read_post()
686 php_cli_server_client *client = SG(server_context); in sapi_cli_server_register_variables() local
689 …"DOCUMENT_ROOT", strlen("DOCUMENT_ROOT"), client->server->document_root, client->server->document_… in sapi_cli_server_register_variables()
692 if ((tmp = strrchr(ZSTR_VAL(client->addr_str), ':'))) { in sapi_cli_server_register_variables()
694 const char *addr_start = ZSTR_VAL(client->addr_str), *addr_end = tmp; in sapi_cli_server_register_variables()
710 "REMOTE_ADDR", strlen("REMOTE_ADDR"), client->addr_str); in sapi_cli_server_register_variables()
719 …zend_string *tmp = strpprintf(0, "HTTP/%d.%d", client->request.protocol_version / 100, client->req… in sapi_cli_server_register_variables()
724 "SERVER_NAME", strlen("SERVER_NAME"), client->server->host, strlen(client->server->host)); in sapi_cli_server_register_variables()
726 zend_string *tmp = strpprintf(0, "%i", client->server->port); in sapi_cli_server_register_variables()
732 "REQUEST_URI", strlen("REQUEST_URI"), client->request.request_uri); in sapi_cli_server_register_variables()
737 "SCRIPT_NAME", strlen("SCRIPT_NAME"), client->request.vpath, client->request.vpath_len); in sapi_cli_server_register_variables()
742 } else if (client->server->router) { in sapi_cli_server_register_variables()
744 … "SCRIPT_FILENAME", strlen("SCRIPT_FILENAME"), client->server->router, client->server->router_len); in sapi_cli_server_register_variables()
746 if (client->request.path_info) { in sapi_cli_server_register_variables()
748 "PATH_INFO", strlen("PATH_INFO"), client->request.path_info, client->request.path_info_len); in sapi_cli_server_register_variables()
750 if (client->request.path_info_len) { in sapi_cli_server_register_variables()
751 zend_string *tmp = strpprintf(0, "%s%s", client->request.vpath, client->request.path_info); in sapi_cli_server_register_variables()
756 "PHP_SELF", strlen("PHP_SELF"), client->request.vpath, client->request.vpath_len); in sapi_cli_server_register_variables()
758 if (client->request.query_string) { in sapi_cli_server_register_variables()
761 sapi_cli_server_register_variable(track_vars_array, "QUERY_STRING", client->request.query_string); in sapi_cli_server_register_variables()
765 …zend_hash_apply_with_arguments(&client->request.headers, (apply_func_args_t)sapi_cli_server_regist… in sapi_cli_server_register_variables()
1185 static void php_cli_server_log_response(php_cli_server_client *client, int status, const char *mess… in php_cli_server_log_response() argument
1218 spprintf(&basic_buf, 0, "%s [%d]: %s %s", ZSTR_VAL(client->addr_str), status, in php_cli_server_log_response()
1219 php_http_method_str(client->request.request_method), ZSTR_VAL(client->request.request_uri)); in php_cli_server_log_response()
1628 php_cli_server_client *client = parser->data; in php_cli_server_client_read_request_on_path() local
1632 if (UNEXPECTED(client->request.vpath != NULL)) { in php_cli_server_client_read_request_on_path()
1636 client->request.vpath = vpath; in php_cli_server_client_read_request_on_path()
1637 client->request.vpath_len = vpath_len; in php_cli_server_client_read_request_on_path()
1644 php_cli_server_client *client = parser->data; in php_cli_server_client_read_request_on_query_string() local
1645 if (EXPECTED(client->request.query_string == NULL)) { in php_cli_server_client_read_request_on_query_string()
1646 client->request.query_string = pestrndup(at, length, 1); in php_cli_server_client_read_request_on_query_string()
1647 client->request.query_string_len = length; in php_cli_server_client_read_request_on_query_string()
1649 …ZEND_ASSERT(length <= PHP_HTTP_MAX_HEADER_SIZE && PHP_HTTP_MAX_HEADER_SIZE - length >= client->req… in php_cli_server_client_read_request_on_query_string()
1650 …client->request.query_string = perealloc(client->request.query_string, client->request.query_strin… in php_cli_server_client_read_request_on_query_string()
1651 memcpy(client->request.query_string + client->request.query_string_len, at, length); in php_cli_server_client_read_request_on_query_string()
1652 client->request.query_string_len += length; in php_cli_server_client_read_request_on_query_string()
1653 client->request.query_string[client->request.query_string_len] = '\0'; in php_cli_server_client_read_request_on_query_string()
1660 php_cli_server_client *client = parser->data; in php_cli_server_client_read_request_on_url() local
1661 if (EXPECTED(client->request.request_uri == NULL)) { in php_cli_server_client_read_request_on_url()
1662 client->request.request_method = parser->method; in php_cli_server_client_read_request_on_url()
1663 client->request.request_uri = zend_string_init(at, length, /* persistent */ true); in php_cli_server_client_read_request_on_url()
1664 GC_MAKE_PERSISTENT_LOCAL(client->request.request_uri); in php_cli_server_client_read_request_on_url()
1666 ZEND_ASSERT(client->request.request_method == parser->method); in php_cli_server_client_read_request_on_url()
1667 …ZEND_ASSERT(length <= PHP_HTTP_MAX_HEADER_SIZE && PHP_HTTP_MAX_HEADER_SIZE - length >= client->req… in php_cli_server_client_read_request_on_url()
1669 …client->request.request_uri = cli_concat_persistent_zstr_with_char(client->request.request_uri, at… in php_cli_server_client_read_request_on_url()
1679 static void php_cli_server_client_save_header(php_cli_server_client *client) in php_cli_server_client_save_header() argument
1684 …zend_string *lc_header_name = zend_string_tolower_ex(client->current_header_name, /* persistent */… in php_cli_server_client_save_header()
1687 zval *entry = zend_hash_find(&client->request.headers, lc_header_name); in php_cli_server_client_save_header()
1695 ZVAL_STR(&tmp, client->current_header_value); in php_cli_server_client_save_header()
1698 …zend_string *newval = zend_string_safe_alloc(1, ZSTR_LEN(curval), ZSTR_LEN(client->current_header… in php_cli_server_client_save_header()
1702 …py(ZSTR_VAL(newval) + ZSTR_LEN(curval) + 2, ZSTR_VAL(client->current_header_value), ZSTR_LEN(clien… in php_cli_server_client_save_header()
1708 zend_hash_update(&client->request.headers, lc_header_name, &tmp); in php_cli_server_client_save_header()
1709 zend_hash_update(&client->request.headers_original_case, client->current_header_name, &tmp); in php_cli_server_client_save_header()
1712 zend_string_release_ex(client->current_header_name, /* persistent */ true); in php_cli_server_client_save_header()
1714 client->current_header_name = NULL; in php_cli_server_client_save_header()
1715 client->current_header_value = NULL; in php_cli_server_client_save_header()
1734 php_cli_server_client *client = parser->data; in php_cli_server_client_read_request_on_header_field() local
1735 switch (client->last_header_element) { in php_cli_server_client_read_request_on_header_field()
1738 php_cli_server_client_save_header(client); in php_cli_server_client_read_request_on_header_field()
1742 client->current_header_name = zend_string_init(at, length, /* persistent */ true); in php_cli_server_client_read_request_on_header_field()
1743 GC_MAKE_PERSISTENT_LOCAL(client->current_header_name); in php_cli_server_client_read_request_on_header_field()
1747 …client->current_header_name = cli_concat_persistent_zstr_with_char(client->current_header_name, at… in php_cli_server_client_read_request_on_header_field()
1752 client->last_header_element = HEADER_FIELD; in php_cli_server_client_read_request_on_header_field()
1758 php_cli_server_client *client = parser->data; in php_cli_server_client_read_request_on_header_value() local
1759 switch (client->last_header_element) { in php_cli_server_client_read_request_on_header_value()
1762 client->current_header_value = zend_string_init(at, length, /* persistent */ true); in php_cli_server_client_read_request_on_header_value()
1763 GC_MAKE_PERSISTENT_LOCAL(client->current_header_value); in php_cli_server_client_read_request_on_header_value()
1767 …client->current_header_value = cli_concat_persistent_zstr_with_char(client->current_header_value, … in php_cli_server_client_read_request_on_header_value()
1775 client->last_header_element = HEADER_VALUE; in php_cli_server_client_read_request_on_header_value()
1781 php_cli_server_client *client = parser->data; in php_cli_server_client_read_request_on_headers_complete() local
1782 switch (client->last_header_element) { in php_cli_server_client_read_request_on_headers_complete()
1787 client->current_header_value = ZSTR_EMPTY_ALLOC(); in php_cli_server_client_read_request_on_headers_complete()
1791 php_cli_server_client_save_header(client); in php_cli_server_client_read_request_on_headers_complete()
1794 client->last_header_element = HEADER_NONE; in php_cli_server_client_read_request_on_headers_complete()
1800 php_cli_server_client *client = parser->data; in php_cli_server_client_read_request_on_body() local
1801 if (!client->request.content) { in php_cli_server_client_read_request_on_body()
1802 client->request.content = pemalloc(parser->content_length, 1); in php_cli_server_client_read_request_on_body()
1803 client->request.content_len = 0; in php_cli_server_client_read_request_on_body()
1805 …client->request.content = perealloc(client->request.content, client->request.content_len + length,… in php_cli_server_client_read_request_on_body()
1806 memmove(client->request.content + client->request.content_len, at, length); in php_cli_server_client_read_request_on_body()
1807 client->request.content_len += length; in php_cli_server_client_read_request_on_body()
1813 php_cli_server_client *client = parser->data; in php_cli_server_client_read_request_on_message_complete() local
1814 client->request.protocol_version = parser->http_major * 100 + parser->http_minor; in php_cli_server_client_read_request_on_message_complete()
1815 …php_cli_server_request_translate_vpath(client->server, &client->request, client->server->document_… in php_cli_server_client_read_request_on_message_complete()
1816 if (client->request.vpath) { in php_cli_server_client_read_request_on_message_complete()
1817 const char *vpath = client->request.vpath; in php_cli_server_client_read_request_on_message_complete()
1818 const char *end = vpath + client->request.vpath_len; in php_cli_server_client_read_request_on_message_complete()
1820 client->request.ext = end; in php_cli_server_client_read_request_on_message_complete()
1821 client->request.ext_len = 0; in php_cli_server_client_read_request_on_message_complete()
1826 client->request.ext = p; in php_cli_server_client_read_request_on_message_complete()
1827 client->request.ext_len = end - p; in php_cli_server_client_read_request_on_message_complete()
1832 client->request_read = true; in php_cli_server_client_read_request_on_message_complete()
1841 static int php_cli_server_client_read_request(php_cli_server_client *client, char **errstr) in php_cli_server_client_read_request() argument
1858 if (client->request_read) { in php_cli_server_client_read_request()
1861 nbytes_read = recv(client->sock, buf, sizeof(buf) - 1, 0); in php_cli_server_client_read_request()
1880 client->parser.data = client; in php_cli_server_client_read_request()
1881 nbytes_consumed = php_http_parser_execute(&client->parser, &settings, buf, nbytes_read); in php_cli_server_client_read_request()
1894 return client->request_read ? 1: 0; in php_cli_server_client_read_request()
1898 static size_t php_cli_server_client_send_through(php_cli_server_client *client, const char *str, si… in php_cli_server_client_send_through() argument
1913 nbytes_sent = send(client->sock, str + str_len - nbytes_left, nbytes_left, 0); in php_cli_server_client_send_through()
1917 int nfds = php_pollfd_for(client->sock, POLLOUT, &tv); in php_cli_server_client_send_through()
1936 static void php_cli_server_client_populate_request_info(const php_cli_server_client *client, sapi_r… in php_cli_server_client_populate_request_info() argument
1940 request_info->request_method = php_http_method_str(client->request.request_method); in php_cli_server_client_populate_request_info()
1941 request_info->proto_num = client->request.protocol_version; in php_cli_server_client_populate_request_info()
1942 request_info->request_uri = ZSTR_VAL(client->request.request_uri); in php_cli_server_client_populate_request_info()
1943 request_info->path_translated = client->request.path_translated; in php_cli_server_client_populate_request_info()
1944 request_info->query_string = client->request.query_string; in php_cli_server_client_populate_request_info()
1945 request_info->content_length = client->request.content_len; in php_cli_server_client_populate_request_info()
1947 …if (NULL != (val = zend_hash_str_find(&client->request.headers, "content-type", sizeof("content-ty… in php_cli_server_client_populate_request_info()
1957 static void php_cli_server_client_ctor(php_cli_server_client *client, php_cli_server *server, php_s… in php_cli_server_client_ctor() argument
1959 client->server = server; in php_cli_server_client_ctor()
1960 client->sock = client_sock; in php_cli_server_client_ctor()
1961 client->addr = addr; in php_cli_server_client_ctor()
1962 client->addr_len = addr_len; in php_cli_server_client_ctor()
1968 client->addr_str = zend_string_dup(tmp_addr, /* persistent */ true); in php_cli_server_client_ctor()
1969 GC_MAKE_PERSISTENT_LOCAL(client->addr_str); in php_cli_server_client_ctor()
1972 php_http_parser_init(&client->parser, PHP_HTTP_REQUEST); in php_cli_server_client_ctor()
1973 client->request_read = false; in php_cli_server_client_ctor()
1975 client->last_header_element = HEADER_NONE; in php_cli_server_client_ctor()
1976 client->current_header_name = NULL; in php_cli_server_client_ctor()
1977 client->current_header_value = NULL; in php_cli_server_client_ctor()
1979 client->post_read_offset = 0; in php_cli_server_client_ctor()
1981 php_cli_server_request_ctor(&client->request); in php_cli_server_client_ctor()
1983 client->content_sender_initialized = false; in php_cli_server_client_ctor()
1984 client->file_fd = -1; in php_cli_server_client_ctor()
1987 static void php_cli_server_client_dtor(php_cli_server_client *client) /* {{{ */ in php_cli_server_client_dtor() argument
1989 php_cli_server_request_dtor(&client->request); in php_cli_server_client_dtor()
1990 if (client->file_fd >= 0) { in php_cli_server_client_dtor()
1991 close(client->file_fd); in php_cli_server_client_dtor()
1992 client->file_fd = -1; in php_cli_server_client_dtor()
1994 pefree(client->addr, 1); in php_cli_server_client_dtor()
1995 zend_string_release_ex(client->addr_str, /* persistent */ true); in php_cli_server_client_dtor()
1997 if (client->content_sender_initialized) { in php_cli_server_client_dtor()
1999 assert(client->current_header_name == NULL); in php_cli_server_client_dtor()
2000 assert(client->current_header_value == NULL); in php_cli_server_client_dtor()
2001 php_cli_server_content_sender_dtor(&client->content_sender); in php_cli_server_client_dtor()
2005 static void php_cli_server_close_connection(php_cli_server *server, php_cli_server_client *client) … in php_cli_server_close_connection() argument
2007 php_cli_server_logf(PHP_CLI_SERVER_LOG_MESSAGE, "%s Closing", ZSTR_VAL(client->addr_str)); in php_cli_server_close_connection()
2009 zend_hash_index_del(&server->clients, client->sock); in php_cli_server_close_connection()
2012 …li_server_send_error_page(php_cli_server *server, php_cli_server_client *client, int status) /* {{… in php_cli_server_send_error_page() argument
2020 php_cli_server_content_sender_ctor(&client->content_sender); in php_cli_server_send_error_page()
2021 client->content_sender_initialized = true; in php_cli_server_send_error_page()
2023 if (client->request.request_method != PHP_HTTP_HEAD) { in php_cli_server_send_error_page()
2024 …ape_html_entities_ex((const unsigned char *) ZSTR_VAL(client->request.request_uri), ZSTR_LEN(clien… in php_cli_server_send_error_page()
2034 php_cli_server_buffer_append(&client->content_sender.buffer, chunk); in php_cli_server_send_error_page()
2041 php_cli_server_buffer_append(&client->content_sender.buffer, chunk); in php_cli_server_send_error_page()
2049 php_cli_server_buffer_append(&client->content_sender.buffer, chunk); in php_cli_server_send_error_page()
2058 php_cli_server_buffer_append(&client->content_sender.buffer, chunk); in php_cli_server_send_error_page()
2066 php_cli_server_buffer_append(&client->content_sender.buffer, chunk); in php_cli_server_send_error_page()
2073 append_http_status_line(&buffer, client->request.protocol_version, status, 1); in php_cli_server_send_error_page()
2078 append_essential_headers(&buffer, client, 1, NULL); in php_cli_server_send_error_page()
2082 …smart_str_append_unsigned_ex(&buffer, php_cli_server_buffer_size(&client->content_sender.buffer), … in php_cli_server_send_error_page()
2100 php_cli_server_buffer_prepend(&client->content_sender.buffer, chunk); in php_cli_server_send_error_page()
2103 php_cli_server_log_response(client, status, errstr ? errstr : "?"); in php_cli_server_send_error_page()
2104 php_cli_server_poller_add(&server->poller, POLLOUT, client->sock); in php_cli_server_send_error_page()
2123 …ult php_cli_server_dispatch_script(php_cli_server *server, php_cli_server_client *client) /* {{{ */ in php_cli_server_dispatch_script() argument
2125 if (strlen(client->request.path_translated) != client->request.path_translated_len) { in php_cli_server_dispatch_script()
2127 return php_cli_server_send_error_page(server, client, 400); in php_cli_server_dispatch_script()
2138 php_cli_server_log_response(client, SG(sapi_headers).http_response_code, NULL); in php_cli_server_dispatch_script()
2142 …t php_cli_server_begin_send_static(php_cli_server *server, php_cli_server_client *client) /* {{{ */ in php_cli_server_begin_send_static() argument
2147 if (client->request.request_method == PHP_HTTP_DELETE in php_cli_server_begin_send_static()
2148 || client->request.request_method == PHP_HTTP_PUT in php_cli_server_begin_send_static()
2149 || client->request.request_method == PHP_HTTP_PATCH) { in php_cli_server_begin_send_static()
2150 return php_cli_server_send_error_page(server, client, 405); in php_cli_server_begin_send_static()
2153 …if (client->request.path_translated && strlen(client->request.path_translated) != client->request.… in php_cli_server_begin_send_static()
2155 return php_cli_server_send_error_page(server, client, 400); in php_cli_server_begin_send_static()
2164 if (client->request.path_translated && in php_cli_server_begin_send_static()
2165 ('.' == client->request.path_translated[client->request.path_translated_len-1] || in php_cli_server_begin_send_static()
2166 ' ' == client->request.path_translated[client->request.path_translated_len-1])) { in php_cli_server_begin_send_static()
2167 return php_cli_server_send_error_page(server, client, 500); in php_cli_server_begin_send_static()
2170 …fd = client->request.path_translated ? php_win32_ioutil_open(client->request.path_translated, O_RD… in php_cli_server_begin_send_static()
2172 fd = client->request.path_translated ? open(client->request.path_translated, O_RDONLY): -1; in php_cli_server_begin_send_static()
2175 return php_cli_server_send_error_page(server, client, 404); in php_cli_server_begin_send_static()
2178 php_cli_server_content_sender_ctor(&client->content_sender); in php_cli_server_begin_send_static()
2179 client->content_sender_initialized = true; in php_cli_server_begin_send_static()
2180 if (client->request.request_method != PHP_HTTP_HEAD) { in php_cli_server_begin_send_static()
2181 client->file_fd = fd; in php_cli_server_begin_send_static()
2187 const char *mime_type = get_mime_type(server, client->request.ext, client->request.ext_len); in php_cli_server_begin_send_static()
2189 append_http_status_line(&buffer, client->request.protocol_version, status, 1); in php_cli_server_begin_send_static()
2192 php_cli_server_log_response(client, 500, NULL); in php_cli_server_begin_send_static()
2195 append_essential_headers(&buffer, client, 1, NULL); in php_cli_server_begin_send_static()
2205 smart_str_append_unsigned_ex(&buffer, client->request.sb.st_size, 1); in php_cli_server_begin_send_static()
2211 php_cli_server_log_response(client, 500, NULL); in php_cli_server_begin_send_static()
2214 php_cli_server_buffer_append(&client->content_sender.buffer, chunk); in php_cli_server_begin_send_static()
2216 php_cli_server_log_response(client, 200, NULL); in php_cli_server_begin_send_static()
2217 php_cli_server_poller_add(&server->poller, POLLOUT, client->sock); in php_cli_server_begin_send_static()
2222 …t php_cli_server_request_startup(php_cli_server *server, php_cli_server_client *client) { /* {{{ */ in php_cli_server_request_startup() argument
2224 php_cli_server_client_populate_request_info(client, &SG(request_info)); in php_cli_server_request_startup()
2225 …if (NULL != (auth = zend_hash_str_find(&client->request.headers, "authorization", sizeof("authoriz… in php_cli_server_request_startup()
2238 static void php_cli_server_request_shutdown(php_cli_server *server, php_cli_server_client *client) … in php_cli_server_request_shutdown() argument
2240 php_cli_server_close_connection(server, client); in php_cli_server_request_shutdown()
2249 static bool php_cli_server_dispatch_router(php_cli_server *server, php_cli_server_client *client) /… in php_cli_server_dispatch_router() argument
2292 static zend_result php_cli_server_dispatch(php_cli_server *server, php_cli_server_client *client) /… in php_cli_server_dispatch() argument
2295 const char *ext = client->request.ext; in php_cli_server_dispatch()
2297 SG(server_context) = client; in php_cli_server_dispatch()
2298 if (client->request.ext_len != 3 in php_cli_server_dispatch()
2300 || !client->request.path_translated) { in php_cli_server_dispatch()
2305 if (FAILURE == php_cli_server_request_startup(server, client)) { in php_cli_server_dispatch()
2306 php_cli_server_request_shutdown(server, client); in php_cli_server_dispatch()
2312 if (!php_cli_server_dispatch_router(server, client)) { in php_cli_server_dispatch()
2313 php_cli_server_request_shutdown(server, client); in php_cli_server_dispatch()
2320 if (SUCCESS == php_cli_server_dispatch_script(server, client) in php_cli_server_dispatch()
2321 || FAILURE == php_cli_server_send_error_page(server, client, 500)) { in php_cli_server_dispatch()
2325 php_cli_server_request_shutdown(server, client); in php_cli_server_dispatch()
2343 if (FAILURE == php_cli_server_begin_send_static(server, client)) { in php_cli_server_dispatch()
2344 php_cli_server_close_connection(server, client); in php_cli_server_dispatch()
2629 …cli_server_recv_event_read_request(php_cli_server *server, php_cli_server_client *client) /* {{{ */ in php_cli_server_recv_event_read_request() argument
2633 switch (php_cli_server_client_read_request(client, &errstr)) { in php_cli_server_recv_event_read_request()
2636 …if (strcmp(errstr, php_cli_server_request_error_unexpected_eof) == 0 && client->parser.state == s_… in php_cli_server_recv_event_read_request()
2638 … a request; it was probably just an unused speculative preconnection", ZSTR_VAL(client->addr_str)); in php_cli_server_recv_event_read_request()
2640 …php_cli_server_logf(PHP_CLI_SERVER_LOG_ERROR, "%s Invalid request (%s)", ZSTR_VAL(client->addr_str… in php_cli_server_recv_event_read_request()
2644 php_cli_server_close_connection(server, client); in php_cli_server_recv_event_read_request()
2647 if (client->request.request_method == PHP_HTTP_NOT_IMPLEMENTED) { in php_cli_server_recv_event_read_request()
2648 return php_cli_server_send_error_page(server, client, 501); in php_cli_server_recv_event_read_request()
2650 php_cli_server_poller_remove(&server->poller, POLLIN, client->sock); in php_cli_server_recv_event_read_request()
2651 return php_cli_server_dispatch(server, client); in php_cli_server_recv_event_read_request()
2653 php_cli_server_poller_add(&server->poller, POLLIN, client->sock); in php_cli_server_recv_event_read_request()
2661 static zend_result php_cli_server_send_event(php_cli_server *server, php_cli_server_client *client)… in php_cli_server_send_event() argument
2663 if (client->content_sender_initialized) { in php_cli_server_send_event()
2664 if (client->file_fd >= 0 && !client->content_sender.buffer.first) { in php_cli_server_send_event()
2666 … if (!php_cli_server_content_sender_pull(&client->content_sender, client->file_fd, &nbytes_read)) { in php_cli_server_send_event()
2667 php_cli_server_close_connection(server, client); in php_cli_server_send_event()
2671 close(client->file_fd); in php_cli_server_send_event()
2672 client->file_fd = -1; in php_cli_server_send_event()
2677 int err = php_cli_server_content_sender_send(&client->content_sender, client->sock, &nbytes_sent); in php_cli_server_send_event()
2679 php_cli_server_close_connection(server, client); in php_cli_server_send_event()
2683 if (!client->content_sender.buffer.first && client->file_fd < 0) { in php_cli_server_send_event()
2684 php_cli_server_close_connection(server, client); in php_cli_server_send_event()
2702 php_cli_server_client *client = NULL; in php_cli_server_do_event_for_each_fd_callback() local
2723 client = pemalloc(sizeof(php_cli_server_client), 1); in php_cli_server_do_event_for_each_fd_callback()
2725 php_cli_server_client_ctor(client, server, client_sock, sa, socklen); in php_cli_server_do_event_for_each_fd_callback()
2727 php_cli_server_logf(PHP_CLI_SERVER_LOG_MESSAGE, "%s Accepted", ZSTR_VAL(client->addr_str)); in php_cli_server_do_event_for_each_fd_callback()
2729 zend_hash_index_update_ptr(&server->clients, client_sock, client); in php_cli_server_do_event_for_each_fd_callback()
2731 php_cli_server_poller_add(&server->poller, POLLIN, client->sock); in php_cli_server_do_event_for_each_fd_callback()
2733 php_cli_server_client *client; in php_cli_server_do_event_for_each_fd_callback() local
2734 if (NULL != (client = zend_hash_index_find_ptr(&server->clients, fd))) { in php_cli_server_do_event_for_each_fd_callback()
2736 params->rhandler(server, client); in php_cli_server_do_event_for_each_fd_callback()
2739 params->whandler(server, client); in php_cli_server_do_event_for_each_fd_callback()