}
pcgi = &(*pcgi)->cgi_list;
}
- if (wsi->cgi->headers_buf)
+ if (wsi->cgi->headers_buf) {
+ lwsl_debug("close: freed cgi headers\n");
lws_free_set_NULL(wsi->cgi->headers_buf);
+ }
/* we have a cgi going, we must kill it */
wsi->cgi->being_closed = 1;
lws_cgi_kill(wsi);
"content-length: ",
"location: ",
"status: ",
+ "transfer-encoding: chunked",
};
LWS_VISIBLE LWS_EXTERN int
if (n > 512)
n = 512;
+ lwsl_debug("LHCS_DUMP_HEADERS: %d\n", n);
+
m = lws_write(wsi, (unsigned char *)wsi->cgi->headers_dumped,
n, LWS_WRITE_HTTP_HEADERS);
if (m < 0) {
if (wsi->cgi->headers_dumped == wsi->cgi->headers_pos) {
wsi->hdr_state = LHCS_PAYLOAD;
lws_free_set_NULL(wsi->cgi->headers_buf);
+ lwsl_debug("freed cgi headers\n");
} else {
wsi->reason_bf |= 8;
lws_callback_on_writable(wsi);
lwsl_err("OOM\n");
return -1;
}
+
+ lwsl_debug("allocated cgi hdrs\n");
wsi->cgi->headers_pos = wsi->cgi->headers_buf;
wsi->cgi->headers_dumped = wsi->cgi->headers_pos;
wsi->cgi->headers_end = wsi->cgi->headers_buf + n - 1;
if (c == '\x0d')
wsi->hdr_state = LCHS_LF1;
+ if (wsi->hdr_state != LCHS_HEADER &&
+ !significant_hdr[SIGNIFICANT_HDR_TRANSFER_ENCODING][wsi->cgi->match[SIGNIFICANT_HDR_TRANSFER_ENCODING]]) {
+ lwsl_debug("cgi produced chunked\n");
+ wsi->cgi->explicitly_chunked = 1;
+ }
+
/* presence of Location: mandates 302 retcode */
if (wsi->hdr_state != LCHS_HEADER &&
!significant_hdr[SIGNIFICANT_HDR_LOCATION][wsi->cgi->match[SIGNIFICANT_HDR_LOCATION]]) {
lwsl_debug("%s: found PID %d on cgi list\n",
__func__, n);
- if (!cgi->content_length) {
+ if (!cgi->content_length && cgi->explicitly_chunked) {
/*
* well, if he sends chunked... give him 5s after the
* cgi terminated to send buffered