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()
1636 php_cli_server_client *client = parser->data; in php_cli_server_client_read_request_on_path() local
1640 if (UNEXPECTED(client->request.vpath != NULL)) { in php_cli_server_client_read_request_on_path()
1644 client->request.vpath = vpath; in php_cli_server_client_read_request_on_path()
1645 client->request.vpath_len = vpath_len; in php_cli_server_client_read_request_on_path()
1652 php_cli_server_client *client = parser->data; in php_cli_server_client_read_request_on_query_string() local
1653 if (EXPECTED(client->request.query_string == NULL)) { in php_cli_server_client_read_request_on_query_string()
1654 client->request.query_string = pestrndup(at, length, 1); in php_cli_server_client_read_request_on_query_string()
1655 client->request.query_string_len = length; in php_cli_server_client_read_request_on_query_string()
1657 …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()
1658client->request.query_string = perealloc(client->request.query_string, client->request.query_strin… in php_cli_server_client_read_request_on_query_string()
1659 memcpy(client->request.query_string + client->request.query_string_len, at, length); in php_cli_server_client_read_request_on_query_string()
1660 client->request.query_string_len += length; in php_cli_server_client_read_request_on_query_string()
1661 client->request.query_string[client->request.query_string_len] = '\0'; in php_cli_server_client_read_request_on_query_string()
1668 php_cli_server_client *client = parser->data; in php_cli_server_client_read_request_on_url() local
1669 if (EXPECTED(client->request.request_uri == NULL)) { in php_cli_server_client_read_request_on_url()
1670 client->request.request_method = parser->method; in php_cli_server_client_read_request_on_url()
1671 client->request.request_uri = zend_string_init(at, length, /* persistent */ true); in php_cli_server_client_read_request_on_url()
1672 GC_MAKE_PERSISTENT_LOCAL(client->request.request_uri); in php_cli_server_client_read_request_on_url()
1674 ZEND_ASSERT(client->request.request_method == parser->method); in php_cli_server_client_read_request_on_url()
1675 …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()
1677client->request.request_uri = cli_concat_persistent_zstr_with_char(client->request.request_uri, at… in php_cli_server_client_read_request_on_url()
1687 static void php_cli_server_client_save_header(php_cli_server_client *client) in php_cli_server_client_save_header() argument
1692 …zend_string *lc_header_name = zend_string_tolower_ex(client->current_header_name, /* persistent */… in php_cli_server_client_save_header()
1695 zval *entry = zend_hash_find(&client->request.headers, lc_header_name); in php_cli_server_client_save_header()
1703 ZVAL_STR(&tmp, client->current_header_value); in php_cli_server_client_save_header()
1706 …zend_string *newval = zend_string_safe_alloc(1, ZSTR_LEN(curval), ZSTR_LEN(client->current_header… in php_cli_server_client_save_header()
1710 …py(ZSTR_VAL(newval) + ZSTR_LEN(curval) + 2, ZSTR_VAL(client->current_header_value), ZSTR_LEN(clien… in php_cli_server_client_save_header()
1716 zend_hash_update(&client->request.headers, lc_header_name, &tmp); in php_cli_server_client_save_header()
1717 zend_hash_update(&client->request.headers_original_case, client->current_header_name, &tmp); in php_cli_server_client_save_header()
1720 zend_string_release_ex(client->current_header_name, /* persistent */ true); in php_cli_server_client_save_header()
1722 client->current_header_name = NULL; in php_cli_server_client_save_header()
1723 client->current_header_value = NULL; in php_cli_server_client_save_header()
1742 php_cli_server_client *client = parser->data; in php_cli_server_client_read_request_on_header_field() local
1743 switch (client->last_header_element) { in php_cli_server_client_read_request_on_header_field()
1746 php_cli_server_client_save_header(client); in php_cli_server_client_read_request_on_header_field()
1750 client->current_header_name = zend_string_init(at, length, /* persistent */ true); in php_cli_server_client_read_request_on_header_field()
1751 GC_MAKE_PERSISTENT_LOCAL(client->current_header_name); in php_cli_server_client_read_request_on_header_field()
1755client->current_header_name = cli_concat_persistent_zstr_with_char(client->current_header_name, at… in php_cli_server_client_read_request_on_header_field()
1760 client->last_header_element = HEADER_FIELD; in php_cli_server_client_read_request_on_header_field()
1766 php_cli_server_client *client = parser->data; in php_cli_server_client_read_request_on_header_value() local
1767 switch (client->last_header_element) { in php_cli_server_client_read_request_on_header_value()
1770 client->current_header_value = zend_string_init(at, length, /* persistent */ true); in php_cli_server_client_read_request_on_header_value()
1771 GC_MAKE_PERSISTENT_LOCAL(client->current_header_value); in php_cli_server_client_read_request_on_header_value()
1775client->current_header_value = cli_concat_persistent_zstr_with_char(client->current_header_value, … in php_cli_server_client_read_request_on_header_value()
1783 client->last_header_element = HEADER_VALUE; in php_cli_server_client_read_request_on_header_value()
1789 php_cli_server_client *client = parser->data; in php_cli_server_client_read_request_on_headers_complete() local
1790 switch (client->last_header_element) { in php_cli_server_client_read_request_on_headers_complete()
1795 client->current_header_value = ZSTR_EMPTY_ALLOC(); in php_cli_server_client_read_request_on_headers_complete()
1799 php_cli_server_client_save_header(client); in php_cli_server_client_read_request_on_headers_complete()
1802 client->last_header_element = HEADER_NONE; in php_cli_server_client_read_request_on_headers_complete()
1808 php_cli_server_client *client = parser->data; in php_cli_server_client_read_request_on_body() local
1809 if (!client->request.content) { in php_cli_server_client_read_request_on_body()
1810 client->request.content = pemalloc(parser->content_length, 1); in php_cli_server_client_read_request_on_body()
1811 client->request.content_len = 0; in php_cli_server_client_read_request_on_body()
1813client->request.content = perealloc(client->request.content, client->request.content_len + length,… in php_cli_server_client_read_request_on_body()
1814 memmove(client->request.content + client->request.content_len, at, length); in php_cli_server_client_read_request_on_body()
1815 client->request.content_len += length; in php_cli_server_client_read_request_on_body()
1821 php_cli_server_client *client = parser->data; in php_cli_server_client_read_request_on_message_complete() local
1822 client->request.protocol_version = parser->http_major * 100 + parser->http_minor; in php_cli_server_client_read_request_on_message_complete()
1823 …php_cli_server_request_translate_vpath(&client->request, client->server->document_root, client->se… in php_cli_server_client_read_request_on_message_complete()
1824 if (client->request.vpath) { in php_cli_server_client_read_request_on_message_complete()
1825 const char *vpath = client->request.vpath; in php_cli_server_client_read_request_on_message_complete()
1826 const char *end = vpath + client->request.vpath_len; in php_cli_server_client_read_request_on_message_complete()
1828 client->request.ext = end; in php_cli_server_client_read_request_on_message_complete()
1829 client->request.ext_len = 0; in php_cli_server_client_read_request_on_message_complete()
1834 client->request.ext = p; in php_cli_server_client_read_request_on_message_complete()
1835 client->request.ext_len = end - p; in php_cli_server_client_read_request_on_message_complete()
1840 client->request_read = true; in php_cli_server_client_read_request_on_message_complete()
1849 static int php_cli_server_client_read_request(php_cli_server_client *client, char **errstr) in php_cli_server_client_read_request() argument
1866 if (client->request_read) { in php_cli_server_client_read_request()
1869 nbytes_read = recv(client->sock, buf, sizeof(buf) - 1, 0); in php_cli_server_client_read_request()
1888 client->parser.data = client; in php_cli_server_client_read_request()
1889 nbytes_consumed = php_http_parser_execute(&client->parser, &settings, buf, nbytes_read); in php_cli_server_client_read_request()
1902 return client->request_read ? 1: 0; in php_cli_server_client_read_request()
1906 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
1921 nbytes_sent = send(client->sock, str + str_len - nbytes_left, nbytes_left, 0); in php_cli_server_client_send_through()
1925 int nfds = php_pollfd_for(client->sock, POLLOUT, &tv); in php_cli_server_client_send_through()
1944 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
1948 request_info->request_method = php_http_method_str(client->request.request_method); in php_cli_server_client_populate_request_info()
1949 request_info->proto_num = client->request.protocol_version; in php_cli_server_client_populate_request_info()
1950 request_info->request_uri = ZSTR_VAL(client->request.request_uri); in php_cli_server_client_populate_request_info()
1951 request_info->path_translated = client->request.path_translated; in php_cli_server_client_populate_request_info()
1952 request_info->query_string = client->request.query_string; in php_cli_server_client_populate_request_info()
1953 request_info->content_length = client->request.content_len; in php_cli_server_client_populate_request_info()
1955 …if (NULL != (val = zend_hash_str_find(&client->request.headers, "content-type", sizeof("content-ty… in php_cli_server_client_populate_request_info()
1965 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
1967 client->server = server; in php_cli_server_client_ctor()
1968 client->sock = client_sock; in php_cli_server_client_ctor()
1969 client->addr = addr; in php_cli_server_client_ctor()
1970 client->addr_len = addr_len; in php_cli_server_client_ctor()
1976 client->addr_str = zend_string_dup(tmp_addr, /* persistent */ true); in php_cli_server_client_ctor()
1977 GC_MAKE_PERSISTENT_LOCAL(client->addr_str); in php_cli_server_client_ctor()
1980 php_http_parser_init(&client->parser, PHP_HTTP_REQUEST); in php_cli_server_client_ctor()
1981 client->request_read = false; in php_cli_server_client_ctor()
1983 client->last_header_element = HEADER_NONE; in php_cli_server_client_ctor()
1984 client->current_header_name = NULL; in php_cli_server_client_ctor()
1985 client->current_header_value = NULL; in php_cli_server_client_ctor()
1987 client->post_read_offset = 0; in php_cli_server_client_ctor()
1989 php_cli_server_request_ctor(&client->request); in php_cli_server_client_ctor()
1991 client->content_sender_initialized = false; in php_cli_server_client_ctor()
1992 client->file_fd = -1; in php_cli_server_client_ctor()
1995 static void php_cli_server_client_dtor(php_cli_server_client *client) /* {{{ */ in php_cli_server_client_dtor() argument
1997 php_cli_server_request_dtor(&client->request); in php_cli_server_client_dtor()
1998 if (client->file_fd >= 0) { in php_cli_server_client_dtor()
1999 close(client->file_fd); in php_cli_server_client_dtor()
2000 client->file_fd = -1; in php_cli_server_client_dtor()
2002 pefree(client->addr, 1); in php_cli_server_client_dtor()
2003 zend_string_release_ex(client->addr_str, /* persistent */ true); in php_cli_server_client_dtor()
2005 if (client->content_sender_initialized) { in php_cli_server_client_dtor()
2007 assert(client->current_header_name == NULL); in php_cli_server_client_dtor()
2008 assert(client->current_header_value == NULL); in php_cli_server_client_dtor()
2009 php_cli_server_content_sender_dtor(&client->content_sender); in php_cli_server_client_dtor()
2013 static void php_cli_server_close_connection(php_cli_server *server, php_cli_server_client *client) … in php_cli_server_close_connection() argument
2015 php_cli_server_logf(PHP_CLI_SERVER_LOG_MESSAGE, "%s Closing", ZSTR_VAL(client->addr_str)); in php_cli_server_close_connection()
2017 zend_hash_index_del(&server->clients, client->sock); in php_cli_server_close_connection()
2020 …li_server_send_error_page(php_cli_server *server, php_cli_server_client *client, int status) /* {{… in php_cli_server_send_error_page() argument
2028 php_cli_server_content_sender_ctor(&client->content_sender); in php_cli_server_send_error_page()
2029 client->content_sender_initialized = true; in php_cli_server_send_error_page()
2031 if (client->request.request_method != PHP_HTTP_HEAD) { in php_cli_server_send_error_page()
2032 …ape_html_entities_ex((const unsigned char *) ZSTR_VAL(client->request.request_uri), ZSTR_LEN(clien… in php_cli_server_send_error_page()
2042 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()
2057 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()
2074 php_cli_server_buffer_append(&client->content_sender.buffer, chunk); in php_cli_server_send_error_page()
2081 append_http_status_line(&buffer, client->request.protocol_version, status, 1); in php_cli_server_send_error_page()
2086 append_essential_headers(&buffer, client, 1, NULL); in php_cli_server_send_error_page()
2089 …smart_str_append_unsigned_ex(&buffer, php_cli_server_buffer_size(&client->content_sender.buffer), … in php_cli_server_send_error_page()
2107 php_cli_server_buffer_prepend(&client->content_sender.buffer, chunk); in php_cli_server_send_error_page()
2110 php_cli_server_log_response(client, status, errstr ? errstr : "?"); in php_cli_server_send_error_page()
2111 php_cli_server_poller_add(&server->poller, POLLOUT, client->sock); in php_cli_server_send_error_page()
2130 …ult php_cli_server_dispatch_script(php_cli_server *server, php_cli_server_client *client) /* {{{ */ in php_cli_server_dispatch_script() argument
2132 if (strlen(client->request.path_translated) != client->request.path_translated_len) { in php_cli_server_dispatch_script()
2134 return php_cli_server_send_error_page(server, client, 400); in php_cli_server_dispatch_script()
2145 php_cli_server_log_response(client, SG(sapi_headers).http_response_code, NULL); in php_cli_server_dispatch_script()
2149 …t php_cli_server_begin_send_static(php_cli_server *server, php_cli_server_client *client) /* {{{ */ in php_cli_server_begin_send_static() argument
2154 if (client->request.request_method == PHP_HTTP_DELETE in php_cli_server_begin_send_static()
2155 || client->request.request_method == PHP_HTTP_PUT in php_cli_server_begin_send_static()
2156 || client->request.request_method == PHP_HTTP_PATCH) { in php_cli_server_begin_send_static()
2157 return php_cli_server_send_error_page(server, client, 405); in php_cli_server_begin_send_static()
2160 …if (client->request.path_translated && strlen(client->request.path_translated) != client->request.… in php_cli_server_begin_send_static()
2162 return php_cli_server_send_error_page(server, client, 400); in php_cli_server_begin_send_static()
2171 if (client->request.path_translated && in php_cli_server_begin_send_static()
2172 ('.' == client->request.path_translated[client->request.path_translated_len-1] || in php_cli_server_begin_send_static()
2173 ' ' == client->request.path_translated[client->request.path_translated_len-1])) { in php_cli_server_begin_send_static()
2174 return php_cli_server_send_error_page(server, client, 500); in php_cli_server_begin_send_static()
2177 …fd = client->request.path_translated ? php_win32_ioutil_open(client->request.path_translated, O_RD… in php_cli_server_begin_send_static()
2179 fd = client->request.path_translated ? open(client->request.path_translated, O_RDONLY): -1; in php_cli_server_begin_send_static()
2182 return php_cli_server_send_error_page(server, client, 404); in php_cli_server_begin_send_static()
2185 php_cli_server_content_sender_ctor(&client->content_sender); in php_cli_server_begin_send_static()
2186 client->content_sender_initialized = true; in php_cli_server_begin_send_static()
2187 if (client->request.request_method != PHP_HTTP_HEAD) { in php_cli_server_begin_send_static()
2188 client->file_fd = fd; in php_cli_server_begin_send_static()
2194 const char *mime_type = get_mime_type(server, client->request.ext, client->request.ext_len); in php_cli_server_begin_send_static()
2196 append_http_status_line(&buffer, client->request.protocol_version, status, 1); in php_cli_server_begin_send_static()
2199 php_cli_server_log_response(client, 500, NULL); in php_cli_server_begin_send_static()
2202 append_essential_headers(&buffer, client, 1, NULL); in php_cli_server_begin_send_static()
2212 smart_str_append_unsigned_ex(&buffer, client->request.sb.st_size, 1); in php_cli_server_begin_send_static()
2218 php_cli_server_log_response(client, 500, NULL); in php_cli_server_begin_send_static()
2221 php_cli_server_buffer_append(&client->content_sender.buffer, chunk); in php_cli_server_begin_send_static()
2223 php_cli_server_log_response(client, 200, NULL); in php_cli_server_begin_send_static()
2224 php_cli_server_poller_add(&server->poller, POLLOUT, client->sock); in php_cli_server_begin_send_static()
2229 …t php_cli_server_request_startup(php_cli_server *server, php_cli_server_client *client) { /* {{{ */ in php_cli_server_request_startup() argument
2231 php_cli_server_client_populate_request_info(client, &SG(request_info)); in php_cli_server_request_startup()
2232 …if (NULL != (auth = zend_hash_str_find(&client->request.headers, "authorization", sizeof("authoriz… in php_cli_server_request_startup()
2245 static void php_cli_server_request_shutdown(php_cli_server *server, php_cli_server_client *client) … in php_cli_server_request_shutdown() argument
2247 php_cli_server_close_connection(server, client); in php_cli_server_request_shutdown()
2254 static bool php_cli_server_dispatch_router(php_cli_server *server, php_cli_server_client *client) /… in php_cli_server_dispatch_router() argument
2304 static zend_result php_cli_server_dispatch(php_cli_server *server, php_cli_server_client *client) /… in php_cli_server_dispatch() argument
2307 const char *ext = client->request.ext; in php_cli_server_dispatch()
2309 SG(server_context) = client; in php_cli_server_dispatch()
2310 if (client->request.ext_len != 3 in php_cli_server_dispatch()
2312 || !client->request.path_translated) { in php_cli_server_dispatch()
2317 if (FAILURE == php_cli_server_request_startup(server, client)) { in php_cli_server_dispatch()
2318 php_cli_server_request_shutdown(server, client); in php_cli_server_dispatch()
2324 if (!php_cli_server_dispatch_router(server, client)) { in php_cli_server_dispatch()
2325 php_cli_server_request_shutdown(server, client); in php_cli_server_dispatch()
2332 if (SUCCESS == php_cli_server_dispatch_script(server, client) in php_cli_server_dispatch()
2333 || FAILURE == php_cli_server_send_error_page(server, client, 500)) { in php_cli_server_dispatch()
2337 php_cli_server_request_shutdown(server, client); in php_cli_server_dispatch()
2353 if (FAILURE == php_cli_server_begin_send_static(server, client)) { in php_cli_server_dispatch()
2354 php_cli_server_close_connection(server, client); in php_cli_server_dispatch()
2639 …cli_server_recv_event_read_request(php_cli_server *server, php_cli_server_client *client) /* {{{ */ in php_cli_server_recv_event_read_request() argument
2643 switch (php_cli_server_client_read_request(client, &errstr)) { in php_cli_server_recv_event_read_request()
2646 …if (strcmp(errstr, php_cli_server_request_error_unexpected_eof) == 0 && client->parser.state == s_… in php_cli_server_recv_event_read_request()
2648 … a request; it was probably just an unused speculative preconnection", ZSTR_VAL(client->addr_str)); in php_cli_server_recv_event_read_request()
2650 …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()
2654 php_cli_server_close_connection(server, client); in php_cli_server_recv_event_read_request()
2657 if (client->request.request_method == PHP_HTTP_NOT_IMPLEMENTED) { in php_cli_server_recv_event_read_request()
2658 return php_cli_server_send_error_page(server, client, 501); in php_cli_server_recv_event_read_request()
2660 php_cli_server_poller_remove(&server->poller, POLLIN, client->sock); in php_cli_server_recv_event_read_request()
2661 return php_cli_server_dispatch(server, client); in php_cli_server_recv_event_read_request()
2663 php_cli_server_poller_add(&server->poller, POLLIN, client->sock); in php_cli_server_recv_event_read_request()
2671 static zend_result php_cli_server_send_event(php_cli_server *server, php_cli_server_client *client)… in php_cli_server_send_event() argument
2673 if (client->content_sender_initialized) { in php_cli_server_send_event()
2674 if (client->file_fd >= 0 && !client->content_sender.buffer.first) { in php_cli_server_send_event()
2676 … if (!php_cli_server_content_sender_pull(&client->content_sender, client->file_fd, &nbytes_read)) { in php_cli_server_send_event()
2677 php_cli_server_close_connection(server, client); in php_cli_server_send_event()
2681 close(client->file_fd); in php_cli_server_send_event()
2682 client->file_fd = -1; in php_cli_server_send_event()
2687 int err = php_cli_server_content_sender_send(&client->content_sender, client->sock, &nbytes_sent); in php_cli_server_send_event()
2689 php_cli_server_close_connection(server, client); in php_cli_server_send_event()
2693 if (!client->content_sender.buffer.first && client->file_fd < 0) { in php_cli_server_send_event()
2694 php_cli_server_close_connection(server, client); in php_cli_server_send_event()
2712 php_cli_server_client *client = NULL; in php_cli_server_do_event_for_each_fd_callback() local
2733 client = pemalloc(sizeof(php_cli_server_client), 1); in php_cli_server_do_event_for_each_fd_callback()
2735 php_cli_server_client_ctor(client, server, client_sock, sa, socklen); in php_cli_server_do_event_for_each_fd_callback()
2737 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()
2739 zend_hash_index_update_ptr(&server->clients, client_sock, client); in php_cli_server_do_event_for_each_fd_callback()
2741 php_cli_server_poller_add(&server->poller, POLLIN, client->sock); in php_cli_server_do_event_for_each_fd_callback()
2743 php_cli_server_client *client; in php_cli_server_do_event_for_each_fd_callback() local
2744 if (NULL != (client = zend_hash_index_find_ptr(&server->clients, fd))) { in php_cli_server_do_event_for_each_fd_callback()
2746 params->rhandler(server, client); in php_cli_server_do_event_for_each_fd_callback()
2749 params->whandler(server, client); in php_cli_server_do_event_for_each_fd_callback()