Lines Matching refs:httpd
65 content_cgihandler(bozohttpd_t *httpd, bozo_httpreq_t *request, in content_cgihandler() argument
71 debug((httpd, DEBUG_FAT, "content_cgihandler: trying file %s", file)); in content_cgihandler()
72 map = bozo_match_content_map(httpd, file, 0); in content_cgihandler()
82 struct bozohttpd_t *httpd = request->hr_httpd; in parse_header() local
89 value = bozostrdup(httpd, request, str); in parse_header()
114 finish_cgi_output(bozohttpd_t *httpd, bozo_httpreq_t *request, int in, int nph) in finish_cgi_output() argument
128 (str = bozodgetln(httpd, in, &len, bozo_read)) != NULL) { in finish_cgi_output()
146 debug((httpd, DEBUG_OBESE, in finish_cgi_output()
149 bozo_printf(httpd, "%s %s\r\n", request->hr_proto, in finish_cgi_output()
151 bozo_flush(httpd, stdout); in finish_cgi_output()
157 hdr = bozomalloc(httpd, sizeof *hdr); in finish_cgi_output()
165 debug((httpd, DEBUG_OBESE, in finish_cgi_output()
167 bozo_printf(httpd, in finish_cgi_output()
169 bozo_flush(httpd, stdout); in finish_cgi_output()
173 debug((httpd, DEBUG_OBESE, in finish_cgi_output()
176 bozo_printf(httpd, "%s: %s\r\n", hdr->h_header, in finish_cgi_output()
181 bozo_printf(httpd, "\r\n"); in finish_cgi_output()
182 bozo_flush(httpd, stdout); in finish_cgi_output()
190 wbytes = bozo_write(httpd, STDOUT_FILENO, buf, in finish_cgi_output()
195 bozoerr(httpd, 1, in finish_cgi_output()
203 append_index_html(bozohttpd_t *httpd, char **url) in append_index_html() argument
205 *url = bozorealloc(httpd, *url, in append_index_html()
206 strlen(*url) + strlen(httpd->index_html) + 1); in append_index_html()
207 strcat(*url, httpd->index_html); in append_index_html()
208 debug((httpd, DEBUG_NORMAL, in append_index_html()
216 struct bozohttpd_t *httpd = request->hr_httpd; in parse_search_string() local
226 str = bozostrdup(httpd, request, query); in parse_search_string()
237 args = bozomalloc(httpd, sizeof(*args) * (*args_len + 1)); in parse_search_string()
327 args[i] = bozostrdup(httpd, request, args[i]); in parse_search_string()
343 bozo_cgi_setbin(bozohttpd_t *httpd, const char *path) in bozo_cgi_setbin() argument
345 httpd->cgibin = bozostrdup(httpd, NULL, path); in bozo_cgi_setbin()
346 debug((httpd, DEBUG_OBESE, "cgibin (cgi-bin directory) is %s", in bozo_cgi_setbin()
347 httpd->cgibin)); in bozo_cgi_setbin()
352 bozo_setenv(bozohttpd_t *httpd, const char *env, const char *val, in bozo_setenv() argument
355 char *s1 = bozomalloc(httpd, strlen(env) + strlen(val) + 2); in bozo_setenv()
360 debug((httpd, DEBUG_OBESE, "bozo_setenv: %s", s1)); in bozo_setenv()
373 bozohttpd_t *httpd = request->hr_httpd; in bozo_process_cgi() local
388 if (!httpd->cgibin && !httpd->process_cgi) in bozo_process_cgi()
392 if (request->hr_user && !httpd->enable_cgi_users) in bozo_process_cgi()
402 file = bozostrdup(httpd, request, uri); in bozo_process_cgi()
404 bozoasprintf(httpd, &file, "/%s", uri); in bozo_process_cgi()
407 query = bozostrdup(httpd, request, request->hr_query); in bozo_process_cgi()
411 bozoasprintf(httpd, &url, "%s%s%s", in bozo_process_cgi()
415 debug((httpd, DEBUG_NORMAL, "%s: url `%s'", __func__, url)); in bozo_process_cgi()
428 if (!httpd->cgibin || in bozo_process_cgi()
430 cgihandler = content_cgihandler(httpd, request, file + 1); in bozo_process_cgi()
432 debug((httpd, DEBUG_FAT, in bozo_process_cgi()
437 append_index_html(httpd, &file); in bozo_process_cgi()
438 debug((httpd, DEBUG_NORMAL, "%s: cgihandler `%s'", in bozo_process_cgi()
441 append_index_html(httpd, &file); in bozo_process_cgi()
449 debug((httpd, DEBUG_NORMAL, "parse_search_string args no: %zu", in bozo_process_cgi()
452 debug((httpd, DEBUG_FAT, in bozo_process_cgi()
456 argv = bozomalloc(httpd, sizeof(*argv) * (3 + search_string_argc)); in bozo_process_cgi()
461 path = bozostrdup(httpd, request, cgihandler); in bozo_process_cgi()
465 info = bozostrdup(httpd, request, s); in bozo_process_cgi()
468 path = bozomalloc(httpd, in bozo_process_cgi()
469 strlen(httpd->cgibin) + 1 + strlen(command) + 1); in bozo_process_cgi()
470 strcpy(path, httpd->cgibin); in bozo_process_cgi()
498 debug((httpd, DEBUG_FAT, in bozo_process_cgi()
504 envp = bozomalloc(httpd, sizeof(*envp) * envpsize); in bozo_process_cgi()
512 env = bozomalloc(httpd, 6 + strlen(headp->h_header) + 1 + in bozo_process_cgi()
526 debug((httpd, DEBUG_OBESE, "setting header %s as %s = %s", in bozo_process_cgi()
528 bozo_setenv(httpd, env, headp->h_value, curenvp++); in bozo_process_cgi()
536 bozo_setenv(httpd, "PATH", _PATH_DEFPATH, curenvp++); in bozo_process_cgi()
537 bozo_setenv(httpd, "IFS", " \t\n", curenvp++); in bozo_process_cgi()
538 bozo_setenv(httpd, "SERVER_NAME", BOZOHOST(httpd,request), curenvp++); in bozo_process_cgi()
539 bozo_setenv(httpd, "GATEWAY_INTERFACE", "CGI/1.1", curenvp++); in bozo_process_cgi()
540 bozo_setenv(httpd, "SERVER_PROTOCOL", request->hr_proto, curenvp++); in bozo_process_cgi()
541 bozo_setenv(httpd, "REQUEST_METHOD", request->hr_methodstr, curenvp++); in bozo_process_cgi()
542 bozo_setenv(httpd, "SCRIPT_NAME", file, curenvp++); in bozo_process_cgi()
543 bozo_setenv(httpd, "SCRIPT_FILENAME", file + 1, curenvp++); in bozo_process_cgi()
544 bozo_setenv(httpd, "SERVER_SOFTWARE", httpd->server_software, in bozo_process_cgi()
546 bozo_setenv(httpd, "REQUEST_URI", uri, curenvp++); in bozo_process_cgi()
547 bozo_setenv(httpd, "DATE_GMT", bozo_http_date(date, sizeof(date)), in bozo_process_cgi()
551 bozo_setenv(httpd, "QUERY_STRING", query, curenvp++); in bozo_process_cgi()
553 bozo_setenv(httpd, "QUERY_STRING", "", curenvp++); in bozo_process_cgi()
555 bozo_setenv(httpd, "PATH_INFO", info, curenvp++); in bozo_process_cgi()
557 bozo_setenv(httpd, "CONTENT_TYPE", type, curenvp++); in bozo_process_cgi()
559 bozo_setenv(httpd, "CONTENT_LENGTH", clen, curenvp++); in bozo_process_cgi()
561 bozo_setenv(httpd, "SERVER_PORT", request->hr_serverport, in bozo_process_cgi()
564 bozo_setenv(httpd, "REMOTE_HOST", request->hr_remotehost, in bozo_process_cgi()
567 bozo_setenv(httpd, "REMOTE_ADDR", request->hr_remoteaddr, in bozo_process_cgi()
574 bozo_setenv(httpd, "REDIRECT_STATUS", "200", curenvp++); in bozo_process_cgi()
577 debug((httpd, DEBUG_FAT, "%s: going exec %s with args:", __func__, in bozo_process_cgi()
581 debug((httpd, DEBUG_FAT, "%s: argv[%zu] = `%s'", __func__, in bozo_process_cgi()
586 bozoerr(httpd, 1, "child socketpair failed: %s", in bozo_process_cgi()
600 bozoerr(httpd, 1, "child fork failed: %s", strerror(errno)); in bozo_process_cgi()
609 bozo_daemon_closefds(httpd); in bozo_process_cgi()
613 bozo_http_error(httpd, 404, request, in bozo_process_cgi()
619 bozoerr(httpd, 1, "child exec failed: %s: %s", in bozo_process_cgi()
624 bozoerr(httpd, 1, "child execve returned?!"); in bozo_process_cgi()
640 bozoerr(httpd, 1, "io child fork failed: %s", strerror(errno)); in bozo_process_cgi()
644 finish_cgi_output(httpd, request, sv[0], nph); in bozo_process_cgi()
649 debug((httpd, DEBUG_FAT, "done processing cgi output")); in bozo_process_cgi()
655 while ((rbytes = bozo_read(httpd, STDIN_FILENO, buf, sizeof buf)) > 0) { in bozo_process_cgi()
663 bozoerr(httpd, 1, "write failed: %s", in bozo_process_cgi()
667 debug((httpd, DEBUG_FAT, "done processing cgi input")); in bozo_process_cgi()
684 bozo_add_content_map_cgi(bozohttpd_t *httpd, const char *arg, in bozo_add_content_map_cgi() argument
689 debug((httpd, DEBUG_NORMAL, "bozo_add_content_map_cgi: name %s cgi %s", in bozo_add_content_map_cgi()
692 httpd->process_cgi = 1; in bozo_add_content_map_cgi()
694 map = bozo_get_content_map(httpd, arg); in bozo_add_content_map_cgi()