• Home
  • Raw
  • Download

Lines Matching refs:cgi

77 	struct lws_cgi *cgi = lws_container_of(sul, struct lws_cgi, sul_grace);  in lws_cgi_grace()  local
81 if (!cgi->wsi->http.cgi->post_in_expected) in lws_cgi_grace()
82 cgi->wsi->http.cgi->cgi_transaction_over = 1; in lws_cgi_grace()
84 lws_callback_on_writable(cgi->wsi); in lws_cgi_grace()
99 (int)wsi->http.cgi->post_in_expected); in lws_cgi_reap_cb()
105 lws_sul_schedule(wsi->a.context, wsi->tsi, &wsi->http.cgi->sul_grace, in lws_cgi_reap_cb()
118 struct lws_cgi *cgi; in lws_cgi() local
125 wsi->http.cgi = lws_zalloc(sizeof(*wsi->http.cgi), "new cgi"); in lws_cgi()
126 if (!wsi->http.cgi) { in lws_cgi()
131 wsi->http.cgi->response_code = HTTP_STATUS_OK; in lws_cgi()
133 cgi = wsi->http.cgi; in lws_cgi()
134 cgi->wsi = wsi; /* set cgi's owning wsi */ in lws_cgi()
135 sum = cgi->summary; in lws_cgi()
136 sumend = sum + strlen(cgi->summary) - 1; in lws_cgi()
145 lwsl_wsi_debug(wsi, "adding cgi %p to list", wsi->http.cgi); in lws_cgi()
146 cgi->cgi_list = pt->http.cgi_list; in lws_cgi()
147 pt->http.cgi_list = cgi; in lws_cgi()
161 wsi->http.cgi->gzip_inflate = 1; in lws_cgi()
344 if (!wsi->http.cgi->gzip_inflate && in lws_cgi()
354 wsi->http.cgi->post_in_expected = (lws_filepos_t) in lws_cgi()
373 wsi->http.cgi->implied_chunked = 1; in lws_cgi()
374 wsi->http.cgi->explicitly_chunked = 1; in lws_cgi()
402 info.plsp = &wsi->http.cgi->lsp; in lws_cgi()
415 wsi->http.cgi->lsp = lws_spawn_piped(&info); in lws_cgi()
416 if (!wsi->http.cgi->lsp) { in lws_cgi()
428 wsi->user_space, NULL, (unsigned int)cgi->lsp->child_pid); in lws_cgi()
434 lws_sul_cancel(&wsi->http.cgi->sul_grace); in lws_cgi()
435 lws_free_set_NULL(wsi->http.cgi); in lws_cgi()
468 if (!wsi->http.cgi) in lws_cgi_write_split_stdout_headers()
479 wsi->http.cgi->response_code); in lws_cgi_write_split_stdout_headers()
481 (unsigned int)wsi->http.cgi->response_code, in lws_cgi_write_split_stdout_headers()
484 if (!wsi->http.cgi->explicitly_chunked && in lws_cgi_write_split_stdout_headers()
485 !wsi->http.cgi->content_length && in lws_cgi_write_split_stdout_headers()
511 p = wsi->http.cgi->headers_start; in lws_cgi_write_split_stdout_headers()
512 wsi->http.cgi->headers_start = in lws_cgi_write_split_stdout_headers()
513 wsi->http.cgi->headers_pos; in lws_cgi_write_split_stdout_headers()
514 wsi->http.cgi->headers_dumped = in lws_cgi_write_split_stdout_headers()
515 wsi->http.cgi->headers_start; in lws_cgi_write_split_stdout_headers()
519 while (p < wsi->http.cgi->headers_start) { in lws_cgi_write_split_stdout_headers()
561 p + 1 == wsi->http.cgi->headers_start) { in lws_cgi_write_split_stdout_headers()
571 (unsigned char **)&wsi->http.cgi->headers_pos, in lws_cgi_write_split_stdout_headers()
572 (unsigned char *)wsi->http.cgi->headers_end)) in lws_cgi_write_split_stdout_headers()
586 (unsigned char **)&wsi->http.cgi->headers_pos, in lws_cgi_write_split_stdout_headers()
587 (unsigned char *)wsi->http.cgi->headers_end)) { in lws_cgi_write_split_stdout_headers()
601 n = (int)(wsi->http.cgi->headers_pos - in lws_cgi_write_split_stdout_headers()
602 wsi->http.cgi->headers_dumped); in lws_cgi_write_split_stdout_headers()
609 if (wsi->http.cgi->headers_dumped + n != in lws_cgi_write_split_stdout_headers()
610 wsi->http.cgi->headers_pos) { in lws_cgi_write_split_stdout_headers()
616 (unsigned char *)wsi->http.cgi->headers_dumped, in lws_cgi_write_split_stdout_headers()
622 wsi->http.cgi->headers_dumped += n; in lws_cgi_write_split_stdout_headers()
623 if (wsi->http.cgi->headers_dumped == in lws_cgi_write_split_stdout_headers()
624 wsi->http.cgi->headers_pos) { in lws_cgi_write_split_stdout_headers()
626 lws_free_set_NULL(wsi->http.cgi->headers_buf); in lws_cgi_write_split_stdout_headers()
629 if (wsi->http.cgi->post_in_expected) { in lws_cgi_write_split_stdout_headers()
649 if (!wsi->http.cgi->headers_buf) { in lws_cgi_write_split_stdout_headers()
654 wsi->http.cgi->headers_buf = lws_malloc((unsigned int)n + LWS_PRE, in lws_cgi_write_split_stdout_headers()
656 if (!wsi->http.cgi->headers_buf) { in lws_cgi_write_split_stdout_headers()
662 wsi->http.cgi->headers_start = in lws_cgi_write_split_stdout_headers()
663 wsi->http.cgi->headers_buf + LWS_PRE; in lws_cgi_write_split_stdout_headers()
664 wsi->http.cgi->headers_pos = wsi->http.cgi->headers_start; in lws_cgi_write_split_stdout_headers()
665 wsi->http.cgi->headers_dumped = wsi->http.cgi->headers_pos; in lws_cgi_write_split_stdout_headers()
666 wsi->http.cgi->headers_end = in lws_cgi_write_split_stdout_headers()
667 wsi->http.cgi->headers_buf + n - 1; in lws_cgi_write_split_stdout_headers()
670 wsi->http.cgi->match[n] = 0; in lws_cgi_write_split_stdout_headers()
671 wsi->http.cgi->lp = 0; in lws_cgi_write_split_stdout_headers()
675 n = lws_get_socket_fd(wsi->http.cgi->lsp->stdwsi[LWS_STDOUT]); in lws_cgi_write_split_stdout_headers()
687 if (wsi->http.cgi->headers_pos >= in lws_cgi_write_split_stdout_headers()
688 wsi->http.cgi->headers_end - 4) { in lws_cgi_write_split_stdout_headers()
698 wsi->http.cgi->match[1], wsi->hdr_state); in lws_cgi_write_split_stdout_headers()
709 if (!significant_hdr[n][wsi->http.cgi->match[n]] && in lws_cgi_write_split_stdout_headers()
711 wsi->http.cgi->lp < (int)sizeof(wsi->http.cgi->l) - 1) { in lws_cgi_write_split_stdout_headers()
712 wsi->http.cgi->l[wsi->http.cgi->lp++] = c; in lws_cgi_write_split_stdout_headers()
713 wsi->http.cgi->l[wsi->http.cgi->lp] = '\0'; in lws_cgi_write_split_stdout_headers()
716 wsi->http.cgi->content_length = in lws_cgi_write_split_stdout_headers()
717 (lws_filepos_t)atoll(wsi->http.cgi->l); in lws_cgi_write_split_stdout_headers()
720 wsi->http.cgi->response_code = in lws_cgi_write_split_stdout_headers()
721 atoi(wsi->http.cgi->l); in lws_cgi_write_split_stdout_headers()
723 wsi->http.cgi->response_code); in lws_cgi_write_split_stdout_headers()
730 if (significant_hdr[n][wsi->http.cgi->match[n]]) { in lws_cgi_write_split_stdout_headers()
732 significant_hdr[n][wsi->http.cgi->match[n]]) in lws_cgi_write_split_stdout_headers()
733 wsi->http.cgi->match[n]++; in lws_cgi_write_split_stdout_headers()
735 wsi->http.cgi->match[n] = 0; in lws_cgi_write_split_stdout_headers()
742 *wsi->http.cgi->headers_pos++ = '\x0d'; in lws_cgi_write_split_stdout_headers()
744 *wsi->http.cgi->headers_pos++ = (unsigned char)c; in lws_cgi_write_split_stdout_headers()
750 [wsi->http.cgi->match[ in lws_cgi_write_split_stdout_headers()
753 wsi->http.cgi->explicitly_chunked = 1; in lws_cgi_write_split_stdout_headers()
759 wsi->http.cgi->match[SIGNIFICANT_HDR_LOCATION]]) { in lws_cgi_write_split_stdout_headers()
761 wsi->http.cgi->response_code = 302; in lws_cgi_write_split_stdout_headers()
765 *wsi->http.cgi->headers_pos++ = (unsigned char)c; in lws_cgi_write_split_stdout_headers()
783 wsi->http.cgi->match[n] = 0; in lws_cgi_write_split_stdout_headers()
784 wsi->http.cgi->lp = 0; in lws_cgi_write_split_stdout_headers()
793 wsi->http.cgi->content_length); in lws_cgi_write_split_stdout_headers()
805 *wsi->http.cgi->headers_pos++ = (unsigned char)c; in lws_cgi_write_split_stdout_headers()
808 wsi->http.cgi->match[n] = 0; in lws_cgi_write_split_stdout_headers()
809 wsi->http.cgi->lp = 0; in lws_cgi_write_split_stdout_headers()
823 m = !wsi->http.cgi->implied_chunked && !wsi->mux_substream && in lws_cgi_write_split_stdout_headers()
825 !wsi->http.cgi->content_length; in lws_cgi_write_split_stdout_headers()
826 n = lws_get_socket_fd(wsi->http.cgi->lsp->stdwsi[LWS_STDOUT]); in lws_cgi_write_split_stdout_headers()
863 if (wsi->http.cgi->content_length_seen + (unsigned int)n == in lws_cgi_write_split_stdout_headers()
864 wsi->http.cgi->content_length) in lws_cgi_write_split_stdout_headers()
873 wsi->http.cgi->content_length_seen += (unsigned int)n; in lws_cgi_write_split_stdout_headers()
886 wsi->http.cgi->cgi_transaction_over = 1; in lws_cgi_write_split_stdout_headers()
912 if (!wsi->http.cgi || !wsi->http.cgi->lsp) in lws_cgi_kill()
915 pid = wsi->http.cgi->lsp->child_pid; in lws_cgi_kill()
917 args.stdwsi = &wsi->http.cgi->lsp->stdwsi[0]; in lws_cgi_kill()
918 lws_spawn_piped_kill_child_process(wsi->http.cgi->lsp); in lws_cgi_kill()
922 m = wsi->http.cgi->being_closed; in lws_cgi_kill()
937 struct lws_cgi **pcgi, *cgi = NULL; in lws_cgi_kill_terminated() local
952 cgi = *pcgi; in lws_cgi_kill_terminated()
955 if (cgi->lsp->child_pid <= 0) in lws_cgi_kill_terminated()
959 if (cgi->headers_buf) in lws_cgi_kill_terminated()
963 if (cgi->content_length > cgi->content_length_seen) in lws_cgi_kill_terminated()
966 if (cgi->content_length) { in lws_cgi_kill_terminated()
969 (unsigned long long)cgi->content_length_seen); in lws_cgi_kill_terminated()
979 if (n == cgi->lsp->child_pid) { in lws_cgi_kill_terminated()
981 if (!cgi->content_length) { in lws_cgi_kill_terminated()
987 cgi->chunked_grace++; in lws_cgi_kill_terminated()
992 cgi->lsp->child_pid = 0; in lws_cgi_kill_terminated()
993 lws_cgi_kill(cgi->wsi); in lws_cgi_kill_terminated()
997 cgi = NULL; in lws_cgi_kill_terminated()
1000 if (!cgi) in lws_cgi_kill_terminated()
1010 cgi = *pcgi; in lws_cgi_kill_terminated()
1013 if (!cgi || !cgi->lsp || cgi->lsp->child_pid <= 0) in lws_cgi_kill_terminated()
1017 if (cgi->chunked_grace) { in lws_cgi_kill_terminated()
1018 cgi->chunked_grace++; in lws_cgi_kill_terminated()
1019 if (cgi->chunked_grace < 2) in lws_cgi_kill_terminated()
1025 if (cgi->headers_buf) in lws_cgi_kill_terminated()
1029 if (cgi->content_length > cgi->content_length_seen) in lws_cgi_kill_terminated()
1032 if (cgi->content_length) in lws_cgi_kill_terminated()
1033 lwsl_wsi_debug(cgi->wsi, "expected cont len seen: %lld", in lws_cgi_kill_terminated()
1034 (unsigned long long)cgi->content_length_seen); in lws_cgi_kill_terminated()
1037 if (waitpid(cgi->lsp->child_pid, &status, WNOHANG) > 0) { in lws_cgi_kill_terminated()
1039 if (!cgi->content_length) { in lws_cgi_kill_terminated()
1045 cgi->chunked_grace++; in lws_cgi_kill_terminated()
1050 cgi->lsp->child_pid); in lws_cgi_kill_terminated()
1053 cgi->lsp->child_pid = 0; in lws_cgi_kill_terminated()
1054 lws_cgi_kill(cgi->wsi); in lws_cgi_kill_terminated()
1066 if (!wsi->http.cgi) in lws_cgi_get_stdwsi()
1069 return wsi->http.cgi->lsp->stdwsi[ch]; in lws_cgi_get_stdwsi()
1081 if (*pcgi == wsi->http.cgi) { in lws_cgi_remove_and_kill()
1088 if (wsi->http.cgi->headers_buf) in lws_cgi_remove_and_kill()
1089 lws_free_set_NULL(wsi->http.cgi->headers_buf); in lws_cgi_remove_and_kill()
1092 wsi->http.cgi->being_closed = 1; in lws_cgi_remove_and_kill()