2 56324ebe 2022-07-14 thomas * Copyright (c) 2020-2022 Tracey Emery <tracey@traceyemery.net>
3 56324ebe 2022-07-14 thomas * Copyright (c) 2013 David Gwynne <dlg@openbsd.org>
4 56324ebe 2022-07-14 thomas * Copyright (c) 2013 Florian Obser <florian@openbsd.org>
6 56324ebe 2022-07-14 thomas * Permission to use, copy, modify, and distribute this software for any
7 56324ebe 2022-07-14 thomas * purpose with or without fee is hereby granted, provided that the above
8 56324ebe 2022-07-14 thomas * copyright notice and this permission notice appear in all copies.
10 56324ebe 2022-07-14 thomas * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 56324ebe 2022-07-14 thomas * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 56324ebe 2022-07-14 thomas * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 56324ebe 2022-07-14 thomas * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 56324ebe 2022-07-14 thomas * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 56324ebe 2022-07-14 thomas * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 56324ebe 2022-07-14 thomas * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 56324ebe 2022-07-14 thomas #include <arpa/inet.h>
20 56324ebe 2022-07-14 thomas #include <sys/socket.h>
21 56324ebe 2022-07-14 thomas #include <sys/types.h>
23 56324ebe 2022-07-14 thomas #include <errno.h>
24 56324ebe 2022-07-14 thomas #include <event.h>
25 56324ebe 2022-07-14 thomas #include <stdlib.h>
26 56324ebe 2022-07-14 thomas #include <stdio.h>
27 56324ebe 2022-07-14 thomas #include <string.h>
28 56324ebe 2022-07-14 thomas #include <time.h>
29 56324ebe 2022-07-14 thomas #include <unistd.h>
31 56324ebe 2022-07-14 thomas #include "got_error.h"
33 d7cad54e 2022-07-14 thomas #include "got_compat.h"
35 56324ebe 2022-07-14 thomas #include "proc.h"
36 56324ebe 2022-07-14 thomas #include "gotwebd.h"
38 56324ebe 2022-07-14 thomas size_t fcgi_parse_record(uint8_t *, size_t, struct request *);
39 56324ebe 2022-07-14 thomas void fcgi_parse_begin_request(uint8_t *, uint16_t, struct request *,
40 56324ebe 2022-07-14 thomas uint16_t);
41 56324ebe 2022-07-14 thomas void fcgi_parse_params(uint8_t *, uint16_t, struct request *, uint16_t);
42 56324ebe 2022-07-14 thomas void fcgi_send_response(struct request *, struct fcgi_response *);
44 56324ebe 2022-07-14 thomas void dump_fcgi_record_header(const char *, struct fcgi_record_header *);
45 56324ebe 2022-07-14 thomas void dump_fcgi_begin_request_body(const char *,
46 56324ebe 2022-07-14 thomas struct fcgi_begin_request_body *);
47 56324ebe 2022-07-14 thomas void dump_fcgi_end_request_body(const char *,
48 56324ebe 2022-07-14 thomas struct fcgi_end_request_body *);
50 56324ebe 2022-07-14 thomas extern int cgi_inflight;
51 56324ebe 2022-07-14 thomas extern volatile int client_cnt;
54 56324ebe 2022-07-14 thomas fcgi_request(int fd, short events, void *arg)
56 56324ebe 2022-07-14 thomas struct request *c = arg;
57 56324ebe 2022-07-14 thomas ssize_t n;
58 56324ebe 2022-07-14 thomas size_t parsed = 0;
60 56324ebe 2022-07-14 thomas n = read(fd, c->buf + c->buf_pos + c->buf_len,
61 56324ebe 2022-07-14 thomas FCGI_RECORD_SIZE - c->buf_pos-c->buf_len);
63 56324ebe 2022-07-14 thomas switch (n) {
65 56324ebe 2022-07-14 thomas switch (errno) {
66 56324ebe 2022-07-14 thomas case EINTR:
67 56324ebe 2022-07-14 thomas case EAGAIN:
70 56324ebe 2022-07-14 thomas goto fail;
75 56324ebe 2022-07-14 thomas log_debug("closed connection");
76 56324ebe 2022-07-14 thomas goto fail;
81 56324ebe 2022-07-14 thomas c->buf_len += n;
84 56324ebe 2022-07-14 thomas * Parse the records as they are received. Per the FastCGI
85 56324ebe 2022-07-14 thomas * specification, the server need only receive the FastCGI
86 56324ebe 2022-07-14 thomas * parameter records in full; it is free to begin execution
87 56324ebe 2022-07-14 thomas * at that point, which is what happens here.
90 56324ebe 2022-07-14 thomas parsed = fcgi_parse_record(c->buf + c->buf_pos, c->buf_len, c);
91 56324ebe 2022-07-14 thomas if (parsed != 0) {
92 56324ebe 2022-07-14 thomas c->buf_pos += parsed;
93 56324ebe 2022-07-14 thomas c->buf_len -= parsed;
95 56324ebe 2022-07-14 thomas } while (parsed > 0 && c->buf_len > 0);
97 56324ebe 2022-07-14 thomas /* Make space for further reads */
98 56324ebe 2022-07-14 thomas if (parsed != 0)
99 56324ebe 2022-07-14 thomas if (c->buf_len > 0) {
100 56324ebe 2022-07-14 thomas bcopy(c->buf + c->buf_pos, c->buf, c->buf_len);
101 56324ebe 2022-07-14 thomas c->buf_pos = 0;
105 56324ebe 2022-07-14 thomas fcgi_cleanup_request(c);
109 56324ebe 2022-07-14 thomas fcgi_parse_record(uint8_t *buf, size_t n, struct request *c)
111 56324ebe 2022-07-14 thomas struct fcgi_record_header *h;
113 56324ebe 2022-07-14 thomas if (n < sizeof(struct fcgi_record_header))
114 56324ebe 2022-07-14 thomas return 0;
116 56324ebe 2022-07-14 thomas h = (struct fcgi_record_header*) buf;
118 56324ebe 2022-07-14 thomas dump_fcgi_record("", h);
120 56324ebe 2022-07-14 thomas if (n < sizeof(struct fcgi_record_header) + ntohs(h->content_len)
121 56324ebe 2022-07-14 thomas + h->padding_len)
122 56324ebe 2022-07-14 thomas return 0;
124 56324ebe 2022-07-14 thomas if (h->version != 1)
125 56324ebe 2022-07-14 thomas log_warn("wrong version");
127 56324ebe 2022-07-14 thomas switch (h->type) {
128 56324ebe 2022-07-14 thomas case FCGI_BEGIN_REQUEST:
129 56324ebe 2022-07-14 thomas fcgi_parse_begin_request(buf +
130 56324ebe 2022-07-14 thomas sizeof(struct fcgi_record_header),
131 56324ebe 2022-07-14 thomas ntohs(h->content_len), c, ntohs(h->id));
133 56324ebe 2022-07-14 thomas case FCGI_PARAMS:
134 56324ebe 2022-07-14 thomas fcgi_parse_params(buf + sizeof(struct fcgi_record_header),
135 56324ebe 2022-07-14 thomas ntohs(h->content_len), c, ntohs(h->id));
137 56324ebe 2022-07-14 thomas case FCGI_STDIN:
138 56324ebe 2022-07-14 thomas case FCGI_ABORT_REQUEST:
139 56324ebe 2022-07-14 thomas fcgi_create_end_record(c);
140 56324ebe 2022-07-14 thomas fcgi_cleanup_request(c);
141 56324ebe 2022-07-14 thomas return 0;
143 56324ebe 2022-07-14 thomas log_warn("unimplemented type %d", h->type);
147 56324ebe 2022-07-14 thomas return (sizeof(struct fcgi_record_header) + ntohs(h->content_len)
148 56324ebe 2022-07-14 thomas + h->padding_len);
152 56324ebe 2022-07-14 thomas fcgi_parse_begin_request(uint8_t *buf, uint16_t n,
153 56324ebe 2022-07-14 thomas struct request *c, uint16_t id)
155 56324ebe 2022-07-14 thomas /* XXX -- FCGI_CANT_MPX_CONN */
156 56324ebe 2022-07-14 thomas if (c->request_started) {
157 56324ebe 2022-07-14 thomas log_warn("unexpected FCGI_BEGIN_REQUEST, ignoring");
161 56324ebe 2022-07-14 thomas if (n != sizeof(struct fcgi_begin_request_body)) {
162 56324ebe 2022-07-14 thomas log_warn("wrong size %d != %lu", n,
163 56324ebe 2022-07-14 thomas sizeof(struct fcgi_begin_request_body));
167 56324ebe 2022-07-14 thomas c->request_started = 1;
169 56324ebe 2022-07-14 thomas c->id = id;
170 56324ebe 2022-07-14 thomas SLIST_INIT(&c->env);
171 56324ebe 2022-07-14 thomas c->env_count = 0;
175 56324ebe 2022-07-14 thomas fcgi_parse_params(uint8_t *buf, uint16_t n, struct request *c, uint16_t id)
177 56324ebe 2022-07-14 thomas struct env_val *env_entry;
178 56324ebe 2022-07-14 thomas uint32_t name_len, val_len;
179 56324ebe 2022-07-14 thomas uint8_t *sd, *dr_buf;
181 56324ebe 2022-07-14 thomas if (!c->request_started) {
182 56324ebe 2022-07-14 thomas log_warn("FCGI_PARAMS without FCGI_BEGIN_REQUEST, ignoring");
186 56324ebe 2022-07-14 thomas if (c->id != id) {
187 56324ebe 2022-07-14 thomas log_warn("unexpected id, ignoring");
191 56324ebe 2022-07-14 thomas if (n == 0) {
192 56324ebe 2022-07-14 thomas gotweb_process_request(c);
196 56324ebe 2022-07-14 thomas while (n > 0) {
197 56324ebe 2022-07-14 thomas if (buf[0] >> 7 == 0) {
198 56324ebe 2022-07-14 thomas name_len = buf[0];
202 56324ebe 2022-07-14 thomas if (n > 3) {
203 56324ebe 2022-07-14 thomas name_len = ((buf[0] & 0x7f) << 24) +
204 56324ebe 2022-07-14 thomas (buf[1] << 16) + (buf[2] << 8) + buf[3];
206 56324ebe 2022-07-14 thomas buf += 4;
211 56324ebe 2022-07-14 thomas if (n > 0) {
212 56324ebe 2022-07-14 thomas if (buf[0] >> 7 == 0) {
213 56324ebe 2022-07-14 thomas val_len = buf[0];
217 56324ebe 2022-07-14 thomas if (n > 3) {
218 56324ebe 2022-07-14 thomas val_len = ((buf[0] & 0x7f) << 24) +
219 56324ebe 2022-07-14 thomas (buf[1] << 16) + (buf[2] << 8) +
222 56324ebe 2022-07-14 thomas buf += 4;
229 56324ebe 2022-07-14 thomas if (n < name_len + val_len)
232 56324ebe 2022-07-14 thomas if ((env_entry = malloc(sizeof(struct env_val))) == NULL) {
233 56324ebe 2022-07-14 thomas log_warn("cannot malloc env_entry");
237 56324ebe 2022-07-14 thomas if ((env_entry->val = calloc(sizeof(char), name_len + val_len +
238 56324ebe 2022-07-14 thomas 2)) == NULL) {
239 56324ebe 2022-07-14 thomas log_warn("cannot allocate env_entry->val");
240 56324ebe 2022-07-14 thomas free(env_entry);
244 56324ebe 2022-07-14 thomas bcopy(buf, env_entry->val, name_len);
245 56324ebe 2022-07-14 thomas buf += name_len;
246 56324ebe 2022-07-14 thomas n -= name_len;
248 56324ebe 2022-07-14 thomas env_entry->val[name_len] = '\0';
249 56324ebe 2022-07-14 thomas if (val_len < MAX_QUERYSTRING && strcmp(env_entry->val,
250 56324ebe 2022-07-14 thomas "QUERY_STRING") == 0 && c->querystring[0] == '\0') {
251 56324ebe 2022-07-14 thomas bcopy(buf, c->querystring, val_len);
252 56324ebe 2022-07-14 thomas c->querystring[val_len] = '\0';
254 56324ebe 2022-07-14 thomas if (val_len < GOTWEBD_MAXTEXT && strcmp(env_entry->val,
255 56324ebe 2022-07-14 thomas "HTTP_HOST") == 0 && c->http_host[0] == '\0') {
258 56324ebe 2022-07-14 thomas * lazily get subdomain
259 56324ebe 2022-07-14 thomas * will only get domain if no subdomain exists
260 56324ebe 2022-07-14 thomas * this can still work if gotweb server name is the same
262 56324ebe 2022-07-14 thomas sd = strchr(buf, '.');
264 56324ebe 2022-07-14 thomas *sd = '\0';
266 56324ebe 2022-07-14 thomas bcopy(buf, c->http_host, val_len);
267 56324ebe 2022-07-14 thomas c->http_host[val_len] = '\0';
269 56324ebe 2022-07-14 thomas if (val_len < MAX_DOCUMENT_ROOT && strcmp(env_entry->val,
270 56324ebe 2022-07-14 thomas "DOCUMENT_ROOT") == 0 && c->document_root[0] == '\0') {
272 56324ebe 2022-07-14 thomas /* drop first char, as it's always / */
273 56324ebe 2022-07-14 thomas dr_buf = &buf[1];
275 56324ebe 2022-07-14 thomas bcopy(dr_buf, c->document_root, val_len - 1);
276 56324ebe 2022-07-14 thomas c->document_root[val_len] = '\0';
278 56324ebe 2022-07-14 thomas if (val_len < MAX_SERVER_NAME && strcmp(env_entry->val,
279 56324ebe 2022-07-14 thomas "SERVER_NAME") == 0 && c->server_name[0] == '\0') {
280 56324ebe 2022-07-14 thomas /* drop first char, as it's always / */
282 56324ebe 2022-07-14 thomas bcopy(buf, c->server_name, val_len);
283 56324ebe 2022-07-14 thomas c->server_name[val_len] = '\0';
285 56324ebe 2022-07-14 thomas env_entry->val[name_len] = '=';
287 56324ebe 2022-07-14 thomas bcopy(buf, (env_entry->val) + name_len + 1, val_len);
288 56324ebe 2022-07-14 thomas buf += val_len;
289 56324ebe 2022-07-14 thomas n -= val_len;
291 56324ebe 2022-07-14 thomas SLIST_INSERT_HEAD(&c->env, env_entry, entry);
292 56324ebe 2022-07-14 thomas log_debug("env[%d], %s", c->env_count, env_entry->val);
293 56324ebe 2022-07-14 thomas c->env_count++;
298 56324ebe 2022-07-14 thomas fcgi_timeout(int fd, short events, void *arg)
300 56324ebe 2022-07-14 thomas fcgi_cleanup_request((struct request*) arg);
304 56324ebe 2022-07-14 thomas fcgi_gen_binary_response(struct request *c, const uint8_t *data, int len)
306 56324ebe 2022-07-14 thomas struct fcgi_response *resp;
307 56324ebe 2022-07-14 thomas struct fcgi_record_header *header;
308 56324ebe 2022-07-14 thomas ssize_t n = 0;
311 56324ebe 2022-07-14 thomas if (c->sock->client_status == CLIENT_DISCONNECT)
312 56324ebe 2022-07-14 thomas return -1;
314 56324ebe 2022-07-14 thomas if (data == NULL)
315 56324ebe 2022-07-14 thomas return 0;
317 56324ebe 2022-07-14 thomas if ((resp = calloc(1, sizeof(struct fcgi_response))) == NULL) {
318 56324ebe 2022-07-14 thomas log_warn("%s: cannot calloc fcgi_response", __func__);
319 56324ebe 2022-07-14 thomas return -1;
322 56324ebe 2022-07-14 thomas header = (struct fcgi_record_header*) resp->data;
323 56324ebe 2022-07-14 thomas header->version = 1;
324 56324ebe 2022-07-14 thomas header->type = FCGI_STDOUT;
325 56324ebe 2022-07-14 thomas header->id = htons(c->id);
326 56324ebe 2022-07-14 thomas header->padding_len = 0;
327 56324ebe 2022-07-14 thomas header->reserved = 0;
329 56324ebe 2022-07-14 thomas for (i = 0; i < len; i++) {
330 56324ebe 2022-07-14 thomas resp->data[i+8] = data[i];
334 56324ebe 2022-07-14 thomas header->content_len = htons(n);
335 56324ebe 2022-07-14 thomas resp->data_pos = 0;
336 56324ebe 2022-07-14 thomas resp->data_len = n + sizeof(struct fcgi_record_header);
337 56324ebe 2022-07-14 thomas fcgi_send_response(c, resp);
339 56324ebe 2022-07-14 thomas return 0;
343 56324ebe 2022-07-14 thomas fcgi_gen_response(struct request *c, const char *data)
345 56324ebe 2022-07-14 thomas struct fcgi_response *resp;
346 56324ebe 2022-07-14 thomas struct fcgi_record_header *header;
347 56324ebe 2022-07-14 thomas ssize_t n = 0;
350 56324ebe 2022-07-14 thomas if (c->sock->client_status == CLIENT_DISCONNECT)
351 56324ebe 2022-07-14 thomas return -1;
353 56324ebe 2022-07-14 thomas if (data == NULL)
354 56324ebe 2022-07-14 thomas return 0;
356 56324ebe 2022-07-14 thomas if (strlen(data) == 0)
357 56324ebe 2022-07-14 thomas return 0;
359 56324ebe 2022-07-14 thomas if ((resp = calloc(1, sizeof(struct fcgi_response))) == NULL) {
360 56324ebe 2022-07-14 thomas log_warn("%s: cannot calloc fcgi_response", __func__);
361 56324ebe 2022-07-14 thomas return -1;
364 56324ebe 2022-07-14 thomas header = (struct fcgi_record_header*) resp->data;
365 56324ebe 2022-07-14 thomas header->version = 1;
366 56324ebe 2022-07-14 thomas header->type = FCGI_STDOUT;
367 56324ebe 2022-07-14 thomas header->id = htons(c->id);
368 56324ebe 2022-07-14 thomas header->padding_len = 0;
369 56324ebe 2022-07-14 thomas header->reserved = 0;
371 56324ebe 2022-07-14 thomas for (i = 0; i < strlen(data); i++) {
372 56324ebe 2022-07-14 thomas resp->data[i+8] = data[i];
376 56324ebe 2022-07-14 thomas header->content_len = htons(n);
377 56324ebe 2022-07-14 thomas resp->data_pos = 0;
378 56324ebe 2022-07-14 thomas resp->data_len = n + sizeof(struct fcgi_record_header);
379 56324ebe 2022-07-14 thomas fcgi_send_response(c, resp);
381 56324ebe 2022-07-14 thomas return 0;
385 56324ebe 2022-07-14 thomas fcgi_send_response(struct request *c, struct fcgi_response *resp)
387 56324ebe 2022-07-14 thomas struct fcgi_record_header *header;
388 56324ebe 2022-07-14 thomas struct timespec ts;
389 56324ebe 2022-07-14 thomas size_t padded_len;
390 56324ebe 2022-07-14 thomas int err = 0, th = 2000;
392 56324ebe 2022-07-14 thomas ts.tv_sec = 0;
393 56324ebe 2022-07-14 thomas ts.tv_nsec = 50;
395 56324ebe 2022-07-14 thomas header = (struct fcgi_record_header*)resp->data;
397 56324ebe 2022-07-14 thomas /* The FastCGI spec suggests to align the output buffer */
398 56324ebe 2022-07-14 thomas padded_len = FCGI_ALIGN(resp->data_len);
399 56324ebe 2022-07-14 thomas if (padded_len > resp->data_len) {
400 56324ebe 2022-07-14 thomas /* There should always be FCGI_PADDING_SIZE bytes left */
401 56324ebe 2022-07-14 thomas if (padded_len > FCGI_RECORD_SIZE)
402 56324ebe 2022-07-14 thomas log_warn("response too long");
403 56324ebe 2022-07-14 thomas header->padding_len = padded_len - resp->data_len;
404 56324ebe 2022-07-14 thomas resp->data_len = padded_len;
407 56324ebe 2022-07-14 thomas dump_fcgi_record("resp ", header);
410 56324ebe 2022-07-14 thomas * XXX: add some simple write heuristics here
411 56324ebe 2022-07-14 thomas * On slower VMs, spotty connections, etc., we don't want to go right to
412 56324ebe 2022-07-14 thomas * disconnect. Let's at least try to write the data a few times before
413 56324ebe 2022-07-14 thomas * giving up.
415 56324ebe 2022-07-14 thomas while ((write(c->fd, resp->data + resp->data_pos,
416 56324ebe 2022-07-14 thomas resp->data_len)) == -1) {
417 56324ebe 2022-07-14 thomas nanosleep(&ts, NULL);
419 56324ebe 2022-07-14 thomas if (err == th) {
420 56324ebe 2022-07-14 thomas c->sock->client_status = CLIENT_DISCONNECT;
425 56324ebe 2022-07-14 thomas free(resp);
429 56324ebe 2022-07-14 thomas fcgi_create_end_record(struct request *c)
431 56324ebe 2022-07-14 thomas struct fcgi_response *resp;
432 56324ebe 2022-07-14 thomas struct fcgi_record_header *header;
433 56324ebe 2022-07-14 thomas struct fcgi_end_request_body *end_request;
435 56324ebe 2022-07-14 thomas if ((resp = calloc(1, sizeof(struct fcgi_response))) == NULL) {
436 56324ebe 2022-07-14 thomas log_warn("cannot calloc fcgi_response");
439 56324ebe 2022-07-14 thomas header = (struct fcgi_record_header*) resp->data;
440 56324ebe 2022-07-14 thomas header->version = 1;
441 56324ebe 2022-07-14 thomas header->type = FCGI_END_REQUEST;
442 56324ebe 2022-07-14 thomas header->id = htons(c->id);
443 56324ebe 2022-07-14 thomas header->content_len = htons(sizeof(struct
444 56324ebe 2022-07-14 thomas fcgi_end_request_body));
445 56324ebe 2022-07-14 thomas header->padding_len = 0;
446 56324ebe 2022-07-14 thomas header->reserved = 0;
447 56324ebe 2022-07-14 thomas end_request = (struct fcgi_end_request_body *) (resp->data +
448 56324ebe 2022-07-14 thomas sizeof(struct fcgi_record_header));
449 56324ebe 2022-07-14 thomas end_request->app_status = htonl(0); /* script_status */
450 56324ebe 2022-07-14 thomas end_request->protocol_status = FCGI_REQUEST_COMPLETE;
451 56324ebe 2022-07-14 thomas end_request->reserved[0] = 0;
452 56324ebe 2022-07-14 thomas end_request->reserved[1] = 0;
453 56324ebe 2022-07-14 thomas end_request->reserved[2] = 0;
454 56324ebe 2022-07-14 thomas resp->data_pos = 0;
455 56324ebe 2022-07-14 thomas resp->data_len = sizeof(struct fcgi_end_request_body) +
456 56324ebe 2022-07-14 thomas sizeof(struct fcgi_record_header);
457 56324ebe 2022-07-14 thomas fcgi_send_response(c, resp);
461 56324ebe 2022-07-14 thomas fcgi_cleanup_request(struct request *c)
463 56324ebe 2022-07-14 thomas cgi_inflight--;
464 56324ebe 2022-07-14 thomas client_cnt--;
466 56324ebe 2022-07-14 thomas evtimer_del(&c->tmo);
467 56324ebe 2022-07-14 thomas if (event_initialized(&c->ev))
468 56324ebe 2022-07-14 thomas event_del(&c->ev);
470 56324ebe 2022-07-14 thomas close(c->fd);
471 56324ebe 2022-07-14 thomas gotweb_free_transport(c->t);
476 56324ebe 2022-07-14 thomas dump_fcgi_record(const char *p, struct fcgi_record_header *h)
478 56324ebe 2022-07-14 thomas dump_fcgi_record_header(p, h);
480 56324ebe 2022-07-14 thomas if (h->type == FCGI_BEGIN_REQUEST)
481 56324ebe 2022-07-14 thomas dump_fcgi_begin_request_body(p,
482 56324ebe 2022-07-14 thomas (struct fcgi_begin_request_body *)(h + 1));
483 56324ebe 2022-07-14 thomas else if (h->type == FCGI_END_REQUEST)
484 56324ebe 2022-07-14 thomas dump_fcgi_end_request_body(p,
485 56324ebe 2022-07-14 thomas (struct fcgi_end_request_body *)(h + 1));
489 56324ebe 2022-07-14 thomas dump_fcgi_record_header(const char* p, struct fcgi_record_header *h)
491 56324ebe 2022-07-14 thomas log_debug("%sversion: %d", p, h->version);
492 56324ebe 2022-07-14 thomas log_debug("%stype: %d", p, h->type);
493 56324ebe 2022-07-14 thomas log_debug("%srequestId: %d", p, ntohs(h->id));
494 56324ebe 2022-07-14 thomas log_debug("%scontentLength: %d", p, ntohs(h->content_len));
495 56324ebe 2022-07-14 thomas log_debug("%spaddingLength: %d", p, h->padding_len);
496 56324ebe 2022-07-14 thomas log_debug("%sreserved: %d", p, h->reserved);
500 56324ebe 2022-07-14 thomas dump_fcgi_begin_request_body(const char *p, struct fcgi_begin_request_body *b)
502 56324ebe 2022-07-14 thomas log_debug("%srole %d", p, ntohs(b->role));
503 56324ebe 2022-07-14 thomas log_debug("%sflags %d", p, b->flags);
507 56324ebe 2022-07-14 thomas dump_fcgi_end_request_body(const char *p, struct fcgi_end_request_body *b)
509 56324ebe 2022-07-14 thomas log_debug("%sappStatus: %d", p, ntohl(b->app_status));
510 56324ebe 2022-07-14 thomas log_debug("%sprotocolStatus: %d", p, b->protocol_status);