Lines Matching refs:con

55 #define FCGI_ENV_ADD_CHECK(ret, con) \  argument
57 con->http_status = 400; \
58 con->file_finished = 1; \
1470 connection *con; in fcgi_connection_close() local
1475 con = hctx->remote_conn; in fcgi_connection_close()
1501 con->plugin_ctx[p->id] = NULL; in fcgi_connection_close()
1562 static handler_t fcgi_connection_reset(server *srv, connection *con, void *p_d) { in fcgi_connection_reset() argument
1565 fcgi_connection_close(srv, con->plugin_ctx[p->id]); in fcgi_connection_reset()
1750 static int fcgi_env_add_request_headers(server *srv, connection *con, plugin_data *p) { in fcgi_env_add_request_headers() argument
1753 for (i = 0; i < con->request.headers->used; i++) { in fcgi_env_add_request_headers()
1756 ds = (data_string *)con->request.headers->data[i]; in fcgi_env_add_request_headers()
1781 …NV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_BUF_LEN(srv->tmp_buf), CONST_BUF_LEN(ds->value)),con); in fcgi_env_add_request_headers()
1785 for (i = 0; i < con->environment->used; i++) { in fcgi_env_add_request_headers()
1788 ds = (data_string *)con->environment->data[i]; in fcgi_env_add_request_headers()
1808 …V_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_BUF_LEN(srv->tmp_buf), CONST_BUF_LEN(ds->value)), con); in fcgi_env_add_request_headers()
1830 connection *con = hctx->remote_conn; in fcgi_create_env() local
1831 server_socket *srv_sock = con->srv_socket; in fcgi_create_env()
1852 if (buffer_is_empty(con->conf.server_tag)) { in fcgi_create_env()
1853 …CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("SERVER_SOFTWARE"), CONST_STR_LEN(PACKAGE_DESC)),con) in fcgi_create_env()
1855 …gi_env_add(p->fcgi_env, CONST_STR_LEN("SERVER_SOFTWARE"), CONST_BUF_LEN(con->conf.server_tag)),con) in fcgi_create_env()
1858 if (con->server_name->used) { in fcgi_create_env()
1859 size_t len = con->server_name->used - 1; in fcgi_create_env()
1861 if (con->server_name->ptr[0] == '[') { in fcgi_create_env()
1862 const char *colon = strstr(con->server_name->ptr, "]:"); in fcgi_create_env()
1863 if (colon) len = (colon + 1) - con->server_name->ptr; in fcgi_create_env()
1865 const char *colon = strchr(con->server_name->ptr, ':'); in fcgi_create_env()
1866 if (colon) len = colon - con->server_name->ptr; in fcgi_create_env()
1869 …_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("SERVER_NAME"), con->server_name->ptr, len),con) in fcgi_create_env()
1880 FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("SERVER_NAME"), s, strlen(s)),con) in fcgi_create_env()
1883 …_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("GATEWAY_INTERFACE"), CONST_STR_LEN("CGI/1.1")),con) in fcgi_create_env()
1893 FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("SERVER_PORT"), buf, strlen(buf)),con) in fcgi_create_env()
1898 if (-1 == getsockname(con->fd, &(our_addr.plain), &our_addr_len)) { in fcgi_create_env()
1903 FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("SERVER_ADDR"), s, strlen(s)),con) in fcgi_create_env()
1907 … ntohs(con->dst_addr.plain.sa_family ? con->dst_addr.ipv6.sin6_port : con->dst_addr.ipv4.sin_port) in fcgi_create_env()
1909 ntohs(con->dst_addr.ipv4.sin_port) in fcgi_create_env()
1913 FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("REMOTE_PORT"), buf, strlen(buf)),con) in fcgi_create_env()
1915 s = inet_ntop_cache_get_ip(srv, &(con->dst_addr)); in fcgi_create_env()
1916 FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("REMOTE_ADDR"), s, strlen(s)),con) in fcgi_create_env()
1918 if (!buffer_is_empty(con->authed_user)) { in fcgi_create_env()
1919 …CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("REMOTE_USER"), CONST_BUF_LEN(con->authed_user)),con) in fcgi_create_env()
1922 if (con->request.content_length > 0 && host->mode != FCGI_AUTHORIZER) { in fcgi_create_env()
1926 LI_ltostr(buf, con->request.content_length); in fcgi_create_env()
1927 …CGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("CONTENT_LENGTH"), buf, strlen(buf)),con) in fcgi_create_env()
1938 …DD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("SCRIPT_NAME"), CONST_BUF_LEN(con->uri.path)),con) in fcgi_create_env()
1940 if (!buffer_is_empty(con->request.pathinfo)) { in fcgi_create_env()
1941 …CK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("PATH_INFO"), CONST_BUF_LEN(con->request.pathinfo)),con) in fcgi_create_env()
1948 buffer_copy_string_buffer(p->path, con->physical.basedir); in fcgi_create_env()
1950 buffer_append_string_buffer(p->path, con->request.pathinfo); in fcgi_create_env()
1951 …_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("PATH_TRANSLATED"), CONST_BUF_LEN(p->path)),con) in fcgi_create_env()
1953 FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("PATH_INFO"), CONST_STR_LEN("")),con) in fcgi_create_env()
1972 buffer_append_string_buffer(p->path, con->uri.path); in fcgi_create_env()
1974 …_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("SCRIPT_FILENAME"), CONST_BUF_LEN(p->path)),con) in fcgi_create_env()
1975 …_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("DOCUMENT_ROOT"), CONST_BUF_LEN(host->docroot)),con) in fcgi_create_env()
1977 buffer_copy_string_buffer(p->path, con->physical.path); in fcgi_create_env()
1984 buffer_append_string_buffer(p->path, con->request.pathinfo); in fcgi_create_env()
1987 …_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("SCRIPT_FILENAME"), CONST_BUF_LEN(p->path)),con) in fcgi_create_env()
1988 …cgi_env_add(p->fcgi_env, CONST_STR_LEN("DOCUMENT_ROOT"), CONST_BUF_LEN(con->physical.basedir)),con) in fcgi_create_env()
2006 if (con->request.orig_uri->used >= host->strip_request_uri->used && in fcgi_create_env()
2007 …0 == strncmp(con->request.orig_uri->ptr, host->strip_request_uri->ptr, host->strip_request_uri->us… in fcgi_create_env()
2011 con->request.orig_uri->ptr + (host->strip_request_uri->used - 2), in fcgi_create_env()
2012 con->request.orig_uri->used - (host->strip_request_uri->used - 2) - 1); in fcgi_create_env()
2014 …(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("REQUEST_URI"), CONST_BUF_LEN(con->request.orig_uri)),con) in fcgi_create_env()
2017 …(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("REQUEST_URI"), CONST_BUF_LEN(con->request.orig_uri)),con) in fcgi_create_env()
2019 if (!buffer_is_equal(con->request.uri, con->request.orig_uri)) { in fcgi_create_env()
2020 …HECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("REDIRECT_URI"), CONST_BUF_LEN(con->request.uri)),con) in fcgi_create_env()
2022 if (!buffer_is_empty(con->uri.query)) { in fcgi_create_env()
2023 …_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("QUERY_STRING"), CONST_BUF_LEN(con->uri.query)),con) in fcgi_create_env()
2025 …FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("QUERY_STRING"), CONST_STR_LEN("")),con) in fcgi_create_env()
2028 s = get_http_method_name(con->request.http_method); in fcgi_create_env()
2029 FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("REQUEST_METHOD"), s, strlen(s)),con) in fcgi_create_env()
2030 …v_add(p->fcgi_env, CONST_STR_LEN("REDIRECT_STATUS"), CONST_STR_LEN("200")),con) /* if php is compi… in fcgi_create_env()
2031 s = get_http_version_name(con->request.http_version); in fcgi_create_env()
2032 FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("SERVER_PROTOCOL"), s, strlen(s)),con) in fcgi_create_env()
2035 FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("HTTPS"), CONST_STR_LEN("on")),con) in fcgi_create_env()
2038 FCGI_ENV_ADD_CHECK(fcgi_env_add_request_headers(srv, con, p), con); in fcgi_create_env()
2050 if (con->request.content_length) { in fcgi_create_env()
2051 chunkqueue *req_cq = con->request_content_queue; in fcgi_create_env()
2176 static int fcgi_response_parse(server *srv, connection *con, plugin_data *p, buffer *in) { in fcgi_response_parse() argument
2179 handler_ctx *hctx = con->plugin_ctx[p->id]; in fcgi_response_parse()
2216 !(con->http_status == 0 || in fcgi_response_parse()
2217 con->http_status == 200)) { in fcgi_response_parse()
2222 … if (NULL == (ds = (data_string *)array_get_unused_element(con->response.headers, TYPE_STRING))) { in fcgi_response_parse()
2228 array_insert_unique(con->response.headers, (data_unset *)ds); in fcgi_response_parse()
2235 con->parsed_response |= HTTP_DATE; in fcgi_response_parse()
2240 con->http_status = strtol(value, NULL, 10); in fcgi_response_parse()
2241 con->parsed_response |= HTTP_STATUS; in fcgi_response_parse()
2246 con->parsed_response |= HTTP_LOCATION; in fcgi_response_parse()
2251 con->response.keep_alive = (0 == strcasecmp(value, "Keep-Alive")) ? 1 : 0; in fcgi_response_parse()
2252 con->parsed_response |= HTTP_CONNECTION; in fcgi_response_parse()
2282 if (HANDLER_ERROR == stat_cache_get_entry(srv, con, srv->tmp_buf, &sce)) { in fcgi_response_parse()
2333 http_chunk_append_file(srv, con, srv->tmp_buf, begin_range, range_len); in fcgi_response_parse()
2343 con->response.content_length = strtol(value, NULL, 10); in fcgi_response_parse()
2344 con->parsed_response |= HTTP_CONTENT_LENGTH; in fcgi_response_parse()
2346 if (con->response.content_length < 0) con->response.content_length = 0; in fcgi_response_parse()
2358 joblist_append(srv, con); in fcgi_response_parse()
2361 …if (NULL == (dcls = (data_string *)array_get_unused_element(con->response.headers, TYPE_STRING))) { in fcgi_response_parse()
2367 dcls = (data_string*) array_replace(con->response.headers, (data_unset *)dcls); in fcgi_response_parse()
2370 con->parsed_response |= HTTP_CONTENT_LENGTH; in fcgi_response_parse()
2371 con->response.content_length = sendfile2_content_length; in fcgi_response_parse()
2375 if ((con->parsed_response & HTTP_LOCATION) && in fcgi_response_parse()
2376 !(con->parsed_response & HTTP_STATUS)) { in fcgi_response_parse()
2377 con->http_status = 302; in fcgi_response_parse()
2494 connection *con = hctx->remote_conn; in fcgi_demux_response() local
2569 if (0 == con->file_started) { in fcgi_demux_response()
2602 if (fcgi_response_parse(srv, con, p, hctx->response_header)) { in fcgi_demux_response()
2603 con->http_status = 502; in fcgi_demux_response()
2605 con->file_started = 1; in fcgi_demux_response()
2609 con->file_started = 1; in fcgi_demux_response()
2612 (con->http_status == 0 || in fcgi_demux_response()
2613 con->http_status == 200)) { in fcgi_demux_response()
2619 … (NULL != (ds = (data_string *) array_get_element(con->response.headers, "X-LIGHTTPD-send-file")) in fcgi_demux_response()
2620 || NULL != (ds = (data_string *) array_get_element(con->response.headers, "X-Sendfile")))) { in fcgi_demux_response()
2623 if (HANDLER_ERROR != stat_cache_get_entry(srv, con, ds->value, &sce)) { in fcgi_demux_response()
2625 …if (NULL == (dcls = (data_string *)array_get_unused_element(con->response.headers, TYPE_STRING))) { in fcgi_demux_response()
2629 http_chunk_append_file(srv, con, ds->value, 0, sce->st.st_size); in fcgi_demux_response()
2631 joblist_append(srv, con); in fcgi_demux_response()
2635 dcls = (data_string*) array_replace(con->response.headers, (data_unset *)dcls); in fcgi_demux_response()
2638 con->parsed_response |= HTTP_CONTENT_LENGTH; in fcgi_demux_response()
2639 con->response.content_length = sce->st.st_size; in fcgi_demux_response()
2644 con->http_status = 502; in fcgi_demux_response()
2646 con->file_started = 1; in fcgi_demux_response()
2654 if (con->request.http_version == HTTP_VERSION_1_1 && in fcgi_demux_response()
2655 !(con->parsed_response & HTTP_CONTENT_LENGTH)) { in fcgi_demux_response()
2656 con->response.transfer_encoding = HTTP_TRANSFER_ENCODING_CHUNKED; in fcgi_demux_response()
2659 http_chunk_append_mem(srv, con, c, blen); in fcgi_demux_response()
2660 joblist_append(srv, con); in fcgi_demux_response()
2663 if (con->request.http_version == HTTP_VERSION_1_1 && in fcgi_demux_response()
2664 !(con->parsed_response & HTTP_CONTENT_LENGTH)) { in fcgi_demux_response()
2666 con->response.transfer_encoding = HTTP_TRANSFER_ENCODING_CHUNKED; in fcgi_demux_response()
2669 http_chunk_append_mem(srv, con, packet.b->ptr, packet.b->used); in fcgi_demux_response()
2670 joblist_append(srv, con); in fcgi_demux_response()
2681 con->file_finished = 1; in fcgi_demux_response()
2684 !(con->http_status == 0 || in fcgi_demux_response()
2685 con->http_status == 200)) { in fcgi_demux_response()
2687 http_chunk_append_mem(srv, con, NULL, 0); in fcgi_demux_response()
2688 joblist_append(srv, con); in fcgi_demux_response()
2843 connection *con = hctx->remote_conn; in fcgi_write_request() local
2937 "wait for fd at connection:", con->fd); in fcgi_write_request()
3055 ret = srv->network_backend_write(srv, con, hctx->fd, hctx->wb, MAX_WRITE_LIMIT); in fcgi_write_request()
3111 handler_ctx *hctx = con->plugin_ctx[p->id]; in SUBREQUEST_FUNC()
3117 if (con->mode != p->id) return HANDLER_GO_ON; in SUBREQUEST_FUNC()
3152 con->http_status = 500; in SUBREQUEST_FUNC()
3153 con->mode = DIRECT; in SUBREQUEST_FUNC()
3189 joblist_append(srv, con); /* in case we come from the event-handler */ in SUBREQUEST_FUNC()
3195 buffer_reset(con->physical.path); in SUBREQUEST_FUNC()
3196 con->mode = DIRECT; in SUBREQUEST_FUNC()
3197 con->http_status = 503; in SUBREQUEST_FUNC()
3198 joblist_append(srv, con); /* in case we come from the event-handler */ in SUBREQUEST_FUNC()
3205 buffer_reset(con->physical.path); in SUBREQUEST_FUNC()
3206 con->mode = DIRECT; in SUBREQUEST_FUNC()
3207 if (con->http_status != 400) con->http_status = 503; in SUBREQUEST_FUNC()
3208 joblist_append(srv, con); /* really ? */ in SUBREQUEST_FUNC()
3213 if (con->file_started == 1) { in SUBREQUEST_FUNC()
3228 connection *con = hctx->remote_conn; in fcgi_handle_fdevent() local
3242 (con->http_status == 200 || in fcgi_handle_fdevent()
3243 con->http_status == 0)) { in fcgi_handle_fdevent()
3250 buffer_copy_string_buffer(con->physical.doc_root, host->docroot); in fcgi_handle_fdevent()
3251 buffer_copy_string_buffer(con->physical.basedir, host->docroot); in fcgi_handle_fdevent()
3253 buffer_copy_string_buffer(con->physical.path, host->docroot); in fcgi_handle_fdevent()
3254 buffer_append_string_buffer(con->physical.path, con->uri.path); in fcgi_handle_fdevent()
3257 con->mode = DIRECT; in fcgi_handle_fdevent()
3258 con->http_status = 0; in fcgi_handle_fdevent()
3259 con->file_started = 1; /* fcgi_extension won't touch the request afterwards */ in fcgi_handle_fdevent()
3265 joblist_append(srv, con); in fcgi_handle_fdevent()
3314 if (con->file_started == 0) { in fcgi_handle_fdevent()
3324 "for", con->uri.path, "?", con->uri.query, ", reconnecting"); in fcgi_handle_fdevent()
3332 "for", con->uri.path, "?", con->uri.query, ", closing connection"); in fcgi_handle_fdevent()
3336 connection_set_state(srv, con, CON_STATE_HANDLE_REQUEST); in fcgi_handle_fdevent()
3337 buffer_reset(con->physical.path); in fcgi_handle_fdevent()
3338 con->http_status = 500; in fcgi_handle_fdevent()
3339 con->mode = DIRECT; in fcgi_handle_fdevent()
3347 "for", con->uri.path, "?", con->uri.query, ", terminating connection"); in fcgi_handle_fdevent()
3349 connection_set_state(srv, con, CON_STATE_ERROR); in fcgi_handle_fdevent()
3355 joblist_append(srv, con); in fcgi_handle_fdevent()
3368 return mod_fastcgi_handle_subrequest(srv, con, p); in fcgi_handle_fdevent()
3388 return mod_fastcgi_handle_subrequest(srv, con, p); in fcgi_handle_fdevent()
3399 con->uri.path, "?", con->uri.query, in fcgi_handle_fdevent()
3403 connection_set_state(srv, con, CON_STATE_ERROR); in fcgi_handle_fdevent()
3405 joblist_append(srv, con); in fcgi_handle_fdevent()
3413 connection_set_state(srv, con, CON_STATE_ERROR); in fcgi_handle_fdevent()
3415 joblist_append(srv, con); in fcgi_handle_fdevent()
3422 static int fcgi_patch_connection(server *srv, connection *con, plugin_data *p) { in fcgi_patch_connection() argument
3436 if (!config_check_cond(srv, con, dc)) continue; in fcgi_patch_connection()
3457 static handler_t fcgi_check_extension(server *srv, connection *con, void *p_d, int uri_path_handler… in fcgi_check_extension() argument
3465 if (con->mode != DIRECT) return HANDLER_GO_ON; in fcgi_check_extension()
3468 if (con->file_started == 1) return HANDLER_GO_ON; in fcgi_check_extension()
3470 fn = uri_path_handler ? con->uri.path : con->physical.path; in fcgi_check_extension()
3476 fcgi_patch_connection(srv, con, p); in fcgi_check_extension()
3530 if ((ct_len <= con->uri.path->used -1) && in fcgi_check_extension()
3531 (strncmp(con->uri.path->ptr, ext->key->ptr, ct_len) == 0)) { in fcgi_check_extension()
3563 buffer_reset(con->physical.path); in fcgi_check_extension()
3564 con->http_status = 500; in fcgi_check_extension()
3571 "all handlers for", con->uri.path, "?", con->uri.query, in fcgi_check_extension()
3595 hctx->remote_conn = con; in fcgi_check_extension()
3604 con->plugin_ctx[p->id] = hctx; in fcgi_check_extension()
3606 con->mode = p->id; in fcgi_check_extension()
3608 if (con->conf.log_request_handling) { in fcgi_check_extension()
3644 buffer_copy_string(con->request.pathinfo, con->uri.path->ptr); in fcgi_check_extension()
3645 con->uri.path->used = 1; in fcgi_check_extension()
3646 con->uri.path->ptr[con->uri.path->used - 1] = '\0'; in fcgi_check_extension()
3648 con->uri.path->used > extension->key->used && in fcgi_check_extension()
3649 NULL != (pathinfo = strchr(con->uri.path->ptr + extension->key->used - 1, '/'))) { in fcgi_check_extension()
3652 buffer_copy_string(con->request.pathinfo, pathinfo); in fcgi_check_extension()
3654 con->uri.path->used -= con->request.pathinfo->used - 1; in fcgi_check_extension()
3655 con->uri.path->ptr[con->uri.path->used - 1] = '\0'; in fcgi_check_extension()
3663 hctx->remote_conn = con; in fcgi_check_extension()
3671 con->plugin_ctx[p->id] = hctx; in fcgi_check_extension()
3673 con->mode = p->id; in fcgi_check_extension()
3675 if (con->conf.log_request_handling) { in fcgi_check_extension()
3684 static handler_t fcgi_check_extension_1(server *srv, connection *con, void *p_d) { in fcgi_check_extension_1() argument
3685 return fcgi_check_extension(srv, con, p_d, 1); in fcgi_check_extension_1()
3689 static handler_t fcgi_check_extension_2(server *srv, connection *con, void *p_d) { in fcgi_check_extension_2() argument
3690 return fcgi_check_extension(srv, con, p_d, 0); in fcgi_check_extension_2()
3695 handler_ctx *hctx = con->plugin_ctx[p->id]; in JOBLIST_FUNC()
3723 static handler_t fcgi_connection_close_callback(server *srv, connection *con, void *p_d) { in fcgi_connection_close_callback() argument
3726 fcgi_connection_close(srv, con->plugin_ctx[p->id]); in fcgi_connection_close_callback()