2 8a35f56c 2022-07-16 thomas * Copyright (c) 2020-2022 Tracey Emery <tracey@traceyemery.net>
3 8a35f56c 2022-07-16 thomas * Copyright (c) 2013 David Gwynne <dlg@openbsd.org>
4 8a35f56c 2022-07-16 thomas * Copyright (c) 2013 Florian Obser <florian@openbsd.org>
6 8a35f56c 2022-07-16 thomas * Permission to use, copy, modify, and distribute this software for any
7 8a35f56c 2022-07-16 thomas * purpose with or without fee is hereby granted, provided that the above
8 8a35f56c 2022-07-16 thomas * copyright notice and this permission notice appear in all copies.
10 8a35f56c 2022-07-16 thomas * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 8a35f56c 2022-07-16 thomas * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 8a35f56c 2022-07-16 thomas * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 8a35f56c 2022-07-16 thomas * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 8a35f56c 2022-07-16 thomas * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 8a35f56c 2022-07-16 thomas * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 8a35f56c 2022-07-16 thomas * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 8a35f56c 2022-07-16 thomas #include <arpa/inet.h>
20 8b925c6c 2022-07-16 thomas #include <sys/queue.h>
21 8a35f56c 2022-07-16 thomas #include <sys/socket.h>
22 8a35f56c 2022-07-16 thomas #include <sys/types.h>
23 0335d24d 2022-08-06 thomas #include <sys/uio.h>
25 8a35f56c 2022-07-16 thomas #include <errno.h>
26 8a35f56c 2022-07-16 thomas #include <event.h>
27 79393471 2022-08-27 thomas #include <imsg.h>
28 79393471 2022-08-27 thomas #include <stdarg.h>
29 8a35f56c 2022-07-16 thomas #include <stdlib.h>
30 8a35f56c 2022-07-16 thomas #include <stdio.h>
31 8a35f56c 2022-07-16 thomas #include <string.h>
32 8a35f56c 2022-07-16 thomas #include <time.h>
33 8a35f56c 2022-07-16 thomas #include <unistd.h>
35 8a35f56c 2022-07-16 thomas #include "got_error.h"
37 ff36aeea 2022-07-16 thomas #include "got_compat.h"
39 8a35f56c 2022-07-16 thomas #include "proc.h"
40 8a35f56c 2022-07-16 thomas #include "gotwebd.h"
42 8a35f56c 2022-07-16 thomas size_t fcgi_parse_record(uint8_t *, size_t, struct request *);
43 8a35f56c 2022-07-16 thomas void fcgi_parse_begin_request(uint8_t *, uint16_t, struct request *,
44 8a35f56c 2022-07-16 thomas uint16_t);
45 8a35f56c 2022-07-16 thomas void fcgi_parse_params(uint8_t *, uint16_t, struct request *, uint16_t);
46 e5539f76 2022-08-10 thomas int fcgi_send_response(struct request *, int, const void *, size_t);
48 8a35f56c 2022-07-16 thomas void dump_fcgi_record_header(const char *, struct fcgi_record_header *);
49 8a35f56c 2022-07-16 thomas void dump_fcgi_begin_request_body(const char *,
50 8a35f56c 2022-07-16 thomas struct fcgi_begin_request_body *);
51 8a35f56c 2022-07-16 thomas void dump_fcgi_end_request_body(const char *,
52 8a35f56c 2022-07-16 thomas struct fcgi_end_request_body *);
54 8a35f56c 2022-07-16 thomas extern int cgi_inflight;
55 8a35f56c 2022-07-16 thomas extern volatile int client_cnt;
58 8a35f56c 2022-07-16 thomas fcgi_request(int fd, short events, void *arg)
60 8a35f56c 2022-07-16 thomas struct request *c = arg;
61 8a35f56c 2022-07-16 thomas ssize_t n;
62 8a35f56c 2022-07-16 thomas size_t parsed = 0;
64 8a35f56c 2022-07-16 thomas n = read(fd, c->buf + c->buf_pos + c->buf_len,
65 8a35f56c 2022-07-16 thomas FCGI_RECORD_SIZE - c->buf_pos-c->buf_len);
67 8a35f56c 2022-07-16 thomas switch (n) {
69 8a35f56c 2022-07-16 thomas switch (errno) {
70 8a35f56c 2022-07-16 thomas case EINTR:
71 8a35f56c 2022-07-16 thomas case EAGAIN:
74 8a35f56c 2022-07-16 thomas goto fail;
79 8a35f56c 2022-07-16 thomas log_debug("closed connection");
80 8a35f56c 2022-07-16 thomas goto fail;
85 8a35f56c 2022-07-16 thomas c->buf_len += n;
88 8a35f56c 2022-07-16 thomas * Parse the records as they are received. Per the FastCGI
89 8a35f56c 2022-07-16 thomas * specification, the server need only receive the FastCGI
90 8a35f56c 2022-07-16 thomas * parameter records in full; it is free to begin execution
91 8a35f56c 2022-07-16 thomas * at that point, which is what happens here.
94 8a35f56c 2022-07-16 thomas parsed = fcgi_parse_record(c->buf + c->buf_pos, c->buf_len, c);
95 8a35f56c 2022-07-16 thomas if (parsed != 0) {
96 8a35f56c 2022-07-16 thomas c->buf_pos += parsed;
97 8a35f56c 2022-07-16 thomas c->buf_len -= parsed;
99 8a35f56c 2022-07-16 thomas } while (parsed > 0 && c->buf_len > 0);
101 8a35f56c 2022-07-16 thomas /* Make space for further reads */
102 8a35f56c 2022-07-16 thomas if (parsed != 0)
103 8a35f56c 2022-07-16 thomas if (c->buf_len > 0) {
104 8a35f56c 2022-07-16 thomas bcopy(c->buf + c->buf_pos, c->buf, c->buf_len);
105 8a35f56c 2022-07-16 thomas c->buf_pos = 0;
109 8a35f56c 2022-07-16 thomas fcgi_cleanup_request(c);
113 8a35f56c 2022-07-16 thomas fcgi_parse_record(uint8_t *buf, size_t n, struct request *c)
115 8a35f56c 2022-07-16 thomas struct fcgi_record_header *h;
117 8a35f56c 2022-07-16 thomas if (n < sizeof(struct fcgi_record_header))
118 8a35f56c 2022-07-16 thomas return 0;
120 8a35f56c 2022-07-16 thomas h = (struct fcgi_record_header*) buf;
122 8a35f56c 2022-07-16 thomas dump_fcgi_record("", h);
124 8a35f56c 2022-07-16 thomas if (n < sizeof(struct fcgi_record_header) + ntohs(h->content_len)
125 8a35f56c 2022-07-16 thomas + h->padding_len)
126 8a35f56c 2022-07-16 thomas return 0;
128 8a35f56c 2022-07-16 thomas if (h->version != 1)
129 8a35f56c 2022-07-16 thomas log_warn("wrong version");
131 8a35f56c 2022-07-16 thomas switch (h->type) {
132 8a35f56c 2022-07-16 thomas case FCGI_BEGIN_REQUEST:
133 8a35f56c 2022-07-16 thomas fcgi_parse_begin_request(buf +
134 8a35f56c 2022-07-16 thomas sizeof(struct fcgi_record_header),
135 8a35f56c 2022-07-16 thomas ntohs(h->content_len), c, ntohs(h->id));
137 8a35f56c 2022-07-16 thomas case FCGI_PARAMS:
138 8a35f56c 2022-07-16 thomas fcgi_parse_params(buf + sizeof(struct fcgi_record_header),
139 8a35f56c 2022-07-16 thomas ntohs(h->content_len), c, ntohs(h->id));
141 8a35f56c 2022-07-16 thomas case FCGI_STDIN:
142 8a35f56c 2022-07-16 thomas case FCGI_ABORT_REQUEST:
143 e5539f76 2022-08-10 thomas if (c->sock->client_status != CLIENT_DISCONNECT &&
144 e5539f76 2022-08-10 thomas c->outbuf_len != 0) {
145 e5539f76 2022-08-10 thomas fcgi_send_response(c, FCGI_STDOUT, c->outbuf,
146 e5539f76 2022-08-10 thomas c->outbuf_len);
149 8a35f56c 2022-07-16 thomas fcgi_create_end_record(c);
150 8a35f56c 2022-07-16 thomas fcgi_cleanup_request(c);
151 8a35f56c 2022-07-16 thomas return 0;
153 8a35f56c 2022-07-16 thomas log_warn("unimplemented type %d", h->type);
157 8a35f56c 2022-07-16 thomas return (sizeof(struct fcgi_record_header) + ntohs(h->content_len)
158 8a35f56c 2022-07-16 thomas + h->padding_len);
162 8a35f56c 2022-07-16 thomas fcgi_parse_begin_request(uint8_t *buf, uint16_t n,
163 8a35f56c 2022-07-16 thomas struct request *c, uint16_t id)
165 8a35f56c 2022-07-16 thomas /* XXX -- FCGI_CANT_MPX_CONN */
166 8a35f56c 2022-07-16 thomas if (c->request_started) {
167 8a35f56c 2022-07-16 thomas log_warn("unexpected FCGI_BEGIN_REQUEST, ignoring");
171 8a35f56c 2022-07-16 thomas if (n != sizeof(struct fcgi_begin_request_body)) {
172 8a35f56c 2022-07-16 thomas log_warn("wrong size %d != %lu", n,
173 8a35f56c 2022-07-16 thomas sizeof(struct fcgi_begin_request_body));
177 8a35f56c 2022-07-16 thomas c->request_started = 1;
178 8a35f56c 2022-07-16 thomas c->id = id;
182 8a35f56c 2022-07-16 thomas fcgi_parse_params(uint8_t *buf, uint16_t n, struct request *c, uint16_t id)
184 8a35f56c 2022-07-16 thomas uint32_t name_len, val_len;
185 4630b4b5 2022-09-01 thomas uint8_t *sd, *val;
187 8a35f56c 2022-07-16 thomas if (!c->request_started) {
188 8a35f56c 2022-07-16 thomas log_warn("FCGI_PARAMS without FCGI_BEGIN_REQUEST, ignoring");
192 8a35f56c 2022-07-16 thomas if (c->id != id) {
193 8a35f56c 2022-07-16 thomas log_warn("unexpected id, ignoring");
197 8a35f56c 2022-07-16 thomas if (n == 0) {
198 8a35f56c 2022-07-16 thomas gotweb_process_request(c);
202 8a35f56c 2022-07-16 thomas while (n > 0) {
203 8a35f56c 2022-07-16 thomas if (buf[0] >> 7 == 0) {
204 8a35f56c 2022-07-16 thomas name_len = buf[0];
208 8a35f56c 2022-07-16 thomas if (n > 3) {
209 8a35f56c 2022-07-16 thomas name_len = ((buf[0] & 0x7f) << 24) +
210 8a35f56c 2022-07-16 thomas (buf[1] << 16) + (buf[2] << 8) + buf[3];
212 8a35f56c 2022-07-16 thomas buf += 4;
217 4630b4b5 2022-09-01 thomas if (n == 0)
220 4630b4b5 2022-09-01 thomas if (buf[0] >> 7 == 0) {
221 4630b4b5 2022-09-01 thomas val_len = buf[0];
225 4630b4b5 2022-09-01 thomas if (n > 3) {
226 4630b4b5 2022-09-01 thomas val_len = ((buf[0] & 0x7f) << 24) +
227 4630b4b5 2022-09-01 thomas (buf[1] << 16) + (buf[2] << 8) +
230 4630b4b5 2022-09-01 thomas buf += 4;
235 4630b4b5 2022-09-01 thomas if (n < name_len + val_len)
238 4630b4b5 2022-09-01 thomas val = buf + name_len;
240 4630b4b5 2022-09-01 thomas if (c->querystring[0] == '\0' &&
241 4630b4b5 2022-09-01 thomas val_len < MAX_QUERYSTRING &&
242 4630b4b5 2022-09-01 thomas name_len == 12 &&
243 4630b4b5 2022-09-01 thomas strncmp(buf, "QUERY_STRING", 12) == 0) {
244 4630b4b5 2022-09-01 thomas memcpy(c->querystring, val, val_len);
245 8a35f56c 2022-07-16 thomas c->querystring[val_len] = '\0';
248 4630b4b5 2022-09-01 thomas if (c->http_host[0] == '\0' &&
249 4630b4b5 2022-09-01 thomas val_len < GOTWEBD_MAXTEXT &&
250 4630b4b5 2022-09-01 thomas name_len == 9 &&
251 4630b4b5 2022-09-01 thomas strncmp(buf, "HTTP_HOST", 9) == 0) {
252 4630b4b5 2022-09-01 thomas memcpy(c->http_host, val, val_len);
253 4630b4b5 2022-09-01 thomas c->http_host[val_len] = '\0';
256 8a35f56c 2022-07-16 thomas * lazily get subdomain
257 8a35f56c 2022-07-16 thomas * will only get domain if no subdomain exists
258 8a35f56c 2022-07-16 thomas * this can still work if gotweb server name is the same
260 4630b4b5 2022-09-01 thomas sd = strchr(c->http_host, '.');
262 8a35f56c 2022-07-16 thomas *sd = '\0';
265 4630b4b5 2022-09-01 thomas if (c->script_name[0] == '\0' &&
266 4630b4b5 2022-09-01 thomas val_len < MAX_SCRIPT_NAME &&
267 4630b4b5 2022-09-01 thomas name_len == 11 &&
268 4630b4b5 2022-09-01 thomas strncmp(buf, "SCRIPT_NAME", 11) == 0) {
269 4630b4b5 2022-09-01 thomas memcpy(c->script_name, val, val_len);
270 3f0158b4 2022-08-30 thomas c->script_name[val_len] = '\0';
273 4630b4b5 2022-09-01 thomas if (c->server_name[0] == '\0' &&
274 4630b4b5 2022-09-01 thomas val_len < MAX_SERVER_NAME &&
275 4630b4b5 2022-09-01 thomas name_len == 11 &&
276 4630b4b5 2022-09-01 thomas strncmp(buf, "SERVER_NAME", 11) == 0) {
277 4630b4b5 2022-09-01 thomas memcpy(c->server_name, val, val_len);
278 8a35f56c 2022-07-16 thomas c->server_name[val_len] = '\0';
281 4630b4b5 2022-09-01 thomas buf += name_len + val_len;
282 4630b4b5 2022-09-01 thomas n -= name_len - val_len;
287 8a35f56c 2022-07-16 thomas fcgi_timeout(int fd, short events, void *arg)
289 8a35f56c 2022-07-16 thomas fcgi_cleanup_request((struct request*) arg);
293 55144267 2022-09-07 thomas fcgi_vprintf(struct request *c, const char *fmt, va_list ap)
295 79393471 2022-08-27 thomas char *str;
298 79393471 2022-08-27 thomas r = vasprintf(&str, fmt, ap);
299 79393471 2022-08-27 thomas if (r == -1) {
300 79393471 2022-08-27 thomas log_warn("%s: asprintf", __func__);
301 79393471 2022-08-27 thomas return -1;
304 79393471 2022-08-27 thomas r = fcgi_gen_binary_response(c, str, r);
305 79393471 2022-08-27 thomas free(str);
306 79393471 2022-08-27 thomas return r;
310 55144267 2022-09-07 thomas fcgi_printf(struct request *c, const char *fmt, ...)
312 55144267 2022-09-07 thomas va_list ap;
315 55144267 2022-09-07 thomas va_start(ap, fmt);
316 55144267 2022-09-07 thomas r = fcgi_vprintf(c, fmt, ap);
317 55144267 2022-09-07 thomas va_end(ap);
319 55144267 2022-09-07 thomas return r;
323 8a35f56c 2022-07-16 thomas fcgi_gen_binary_response(struct request *c, const uint8_t *data, int len)
327 8a35f56c 2022-07-16 thomas if (c->sock->client_status == CLIENT_DISCONNECT)
328 8a35f56c 2022-07-16 thomas return -1;
330 0c2c6365 2022-07-28 thomas if (data == NULL || len == 0)
331 8a35f56c 2022-07-16 thomas return 0;
334 e5539f76 2022-08-10 thomas * special case: send big replies -like blobs- directly
335 e5539f76 2022-08-10 thomas * without copying.
337 e5539f76 2022-08-10 thomas if (len > sizeof(c->outbuf)) {
338 e5539f76 2022-08-10 thomas if (c->outbuf_len > 0) {
339 e5539f76 2022-08-10 thomas fcgi_send_response(c, FCGI_STDOUT,
340 e5539f76 2022-08-10 thomas c->outbuf, c->outbuf_len);
341 e5539f76 2022-08-10 thomas c->outbuf_len = 0;
343 e5539f76 2022-08-10 thomas return fcgi_send_response(c, FCGI_STDOUT, data, len);
346 e5539f76 2022-08-10 thomas if (len < sizeof(c->outbuf) - c->outbuf_len) {
347 e5539f76 2022-08-10 thomas memcpy(c->outbuf + c->outbuf_len, data, len);
348 e5539f76 2022-08-10 thomas c->outbuf_len += len;
349 e5539f76 2022-08-10 thomas return 0;
352 e5539f76 2022-08-10 thomas r = fcgi_send_response(c, FCGI_STDOUT, c->outbuf, c->outbuf_len);
353 e5539f76 2022-08-10 thomas if (r == -1)
354 e5539f76 2022-08-10 thomas return -1;
356 e5539f76 2022-08-10 thomas memcpy(c->outbuf, data, len);
357 e5539f76 2022-08-10 thomas c->outbuf_len = len;
358 8a35f56c 2022-07-16 thomas return 0;
361 e5539f76 2022-08-10 thomas static int
362 0335d24d 2022-08-06 thomas send_response(struct request *c, int type, const uint8_t *data,
363 0335d24d 2022-08-06 thomas size_t len)
365 0335d24d 2022-08-06 thomas static const uint8_t padding[FCGI_PADDING_SIZE];
366 0335d24d 2022-08-06 thomas struct fcgi_record_header header;
367 0335d24d 2022-08-06 thomas struct iovec iov[3];
368 8a35f56c 2022-07-16 thomas struct timespec ts;
369 a5a99557 2022-07-29 thomas ssize_t nw;
370 0335d24d 2022-08-06 thomas size_t padded_len, tot;
371 0335d24d 2022-08-06 thomas int i, err = 0, th = 2000;
373 8a35f56c 2022-07-16 thomas ts.tv_sec = 0;
374 8a35f56c 2022-07-16 thomas ts.tv_nsec = 50;
376 0335d24d 2022-08-06 thomas memset(&header, 0, sizeof(header));
377 0335d24d 2022-08-06 thomas header.version = 1;
378 0335d24d 2022-08-06 thomas header.type = type;
379 0335d24d 2022-08-06 thomas header.id = htons(c->id);
380 0335d24d 2022-08-06 thomas header.content_len = htons(len);
382 8a35f56c 2022-07-16 thomas /* The FastCGI spec suggests to align the output buffer */
383 0335d24d 2022-08-06 thomas tot = sizeof(header) + len;
384 0335d24d 2022-08-06 thomas padded_len = FCGI_ALIGN(tot);
385 0335d24d 2022-08-06 thomas if (padded_len > tot) {
386 0335d24d 2022-08-06 thomas header.padding_len = padded_len - tot;
387 0335d24d 2022-08-06 thomas tot += header.padding_len;
390 0335d24d 2022-08-06 thomas iov[0].iov_base = &header;
391 0335d24d 2022-08-06 thomas iov[0].iov_len = sizeof(header);
393 0335d24d 2022-08-06 thomas iov[1].iov_base = (void *)data;
394 0335d24d 2022-08-06 thomas iov[1].iov_len = len;
396 0335d24d 2022-08-06 thomas iov[2].iov_base = (void *)padding;
397 0335d24d 2022-08-06 thomas iov[2].iov_len = header.padding_len;
399 0335d24d 2022-08-06 thomas dump_fcgi_record("resp ", &header);
402 8a35f56c 2022-07-16 thomas * XXX: add some simple write heuristics here
403 8a35f56c 2022-07-16 thomas * On slower VMs, spotty connections, etc., we don't want to go right to
404 8a35f56c 2022-07-16 thomas * disconnect. Let's at least try to write the data a few times before
405 8a35f56c 2022-07-16 thomas * giving up.
407 0335d24d 2022-08-06 thomas while (tot > 0) {
408 0335d24d 2022-08-06 thomas nw = writev(c->fd, iov, nitems(iov));
409 a5a99557 2022-07-29 thomas if (nw == 0) {
410 a5a99557 2022-07-29 thomas c->sock->client_status = CLIENT_DISCONNECT;
413 a5a99557 2022-07-29 thomas if (nw == -1) {
415 a5a99557 2022-07-29 thomas if (errno == EAGAIN && err < th) {
416 a5a99557 2022-07-29 thomas nanosleep(&ts, NULL);
417 a5a99557 2022-07-29 thomas continue;
419 460244b7 2022-07-29 thomas log_warn("%s: write failure", __func__);
420 8a35f56c 2022-07-16 thomas c->sock->client_status = CLIENT_DISCONNECT;
421 e5539f76 2022-08-10 thomas return -1;
424 0335d24d 2022-08-06 thomas if (nw != tot)
425 0335d24d 2022-08-06 thomas log_debug("%s: partial write: %zu vs %zu", __func__,
426 0335d24d 2022-08-06 thomas nw, tot);
428 0335d24d 2022-08-06 thomas tot -= nw;
429 0335d24d 2022-08-06 thomas for (i = 0; i < nitems(iov); ++i) {
430 0335d24d 2022-08-06 thomas if (nw < iov[i].iov_len) {
431 0335d24d 2022-08-06 thomas iov[i].iov_base += nw;
432 0335d24d 2022-08-06 thomas iov[i].iov_len -= nw;
435 0335d24d 2022-08-06 thomas nw -= iov[i].iov_len;
436 0335d24d 2022-08-06 thomas iov[i].iov_len = 0;
440 e5539f76 2022-08-10 thomas return 0;
444 0335d24d 2022-08-06 thomas fcgi_send_response(struct request *c, int type, const void *data,
445 0335d24d 2022-08-06 thomas size_t len)
447 e5539f76 2022-08-10 thomas if (c->sock->client_status == CLIENT_DISCONNECT)
448 e5539f76 2022-08-10 thomas return -1;
450 0335d24d 2022-08-06 thomas while (len > FCGI_CONTENT_SIZE) {
451 e5539f76 2022-08-10 thomas if (send_response(c, type, data, len) == -1)
452 e5539f76 2022-08-10 thomas return -1;
454 0335d24d 2022-08-06 thomas data += FCGI_CONTENT_SIZE;
455 0335d24d 2022-08-06 thomas len -= FCGI_CONTENT_SIZE;
458 0335d24d 2022-08-06 thomas if (len == 0)
459 e5539f76 2022-08-10 thomas return 0;
461 e5539f76 2022-08-10 thomas return send_response(c, type, data, len);
465 8a35f56c 2022-07-16 thomas fcgi_create_end_record(struct request *c)
467 0335d24d 2022-08-06 thomas struct fcgi_end_request_body end_request;
469 0335d24d 2022-08-06 thomas memset(&end_request, 0, sizeof(end_request));
470 0335d24d 2022-08-06 thomas end_request.app_status = htonl(0); /* script status */
471 0335d24d 2022-08-06 thomas end_request.protocol_status = FCGI_REQUEST_COMPLETE;
473 0335d24d 2022-08-06 thomas fcgi_send_response(c, FCGI_END_REQUEST, &end_request,
474 0335d24d 2022-08-06 thomas sizeof(end_request));
478 8a35f56c 2022-07-16 thomas fcgi_cleanup_request(struct request *c)
480 8a35f56c 2022-07-16 thomas cgi_inflight--;
481 8a35f56c 2022-07-16 thomas client_cnt--;
483 8a35f56c 2022-07-16 thomas evtimer_del(&c->tmo);
484 8a35f56c 2022-07-16 thomas if (event_initialized(&c->ev))
485 8a35f56c 2022-07-16 thomas event_del(&c->ev);
487 8a35f56c 2022-07-16 thomas close(c->fd);
488 8a35f56c 2022-07-16 thomas gotweb_free_transport(c->t);
493 8a35f56c 2022-07-16 thomas dump_fcgi_record(const char *p, struct fcgi_record_header *h)
495 8a35f56c 2022-07-16 thomas dump_fcgi_record_header(p, h);
497 8a35f56c 2022-07-16 thomas if (h->type == FCGI_BEGIN_REQUEST)
498 8a35f56c 2022-07-16 thomas dump_fcgi_begin_request_body(p,
499 8a35f56c 2022-07-16 thomas (struct fcgi_begin_request_body *)(h + 1));
500 8a35f56c 2022-07-16 thomas else if (h->type == FCGI_END_REQUEST)
501 8a35f56c 2022-07-16 thomas dump_fcgi_end_request_body(p,
502 8a35f56c 2022-07-16 thomas (struct fcgi_end_request_body *)(h + 1));
506 8a35f56c 2022-07-16 thomas dump_fcgi_record_header(const char* p, struct fcgi_record_header *h)
508 8a35f56c 2022-07-16 thomas log_debug("%sversion: %d", p, h->version);
509 8a35f56c 2022-07-16 thomas log_debug("%stype: %d", p, h->type);
510 8a35f56c 2022-07-16 thomas log_debug("%srequestId: %d", p, ntohs(h->id));
511 8a35f56c 2022-07-16 thomas log_debug("%scontentLength: %d", p, ntohs(h->content_len));
512 8a35f56c 2022-07-16 thomas log_debug("%spaddingLength: %d", p, h->padding_len);
513 8a35f56c 2022-07-16 thomas log_debug("%sreserved: %d", p, h->reserved);
517 8a35f56c 2022-07-16 thomas dump_fcgi_begin_request_body(const char *p, struct fcgi_begin_request_body *b)
519 8a35f56c 2022-07-16 thomas log_debug("%srole %d", p, ntohs(b->role));
520 8a35f56c 2022-07-16 thomas log_debug("%sflags %d", p, b->flags);
524 8a35f56c 2022-07-16 thomas dump_fcgi_end_request_body(const char *p, struct fcgi_end_request_body *b)
526 8a35f56c 2022-07-16 thomas log_debug("%sappStatus: %d", p, ntohl(b->app_status));
527 8a35f56c 2022-07-16 thomas log_debug("%sprotocolStatus: %d", p, b->protocol_status);