From 4d617fd6a9da609fe4b6fe8c0e21c49684dbddc2 Mon Sep 17 00:00:00 2001 From: "me@ow.nekobit.net" Date: Sun, 27 Feb 2022 04:09:57 +0000 Subject: [PATCH] Post debugging FossilOrigin-Name: 138c838089b33777ebb5e987d75e92447c01bb658591757bb4f035826b54b75c --- src/query.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/query.c b/src/query.c index d685694..f649e30 100644 --- a/src/query.c +++ b/src/query.c @@ -28,6 +28,7 @@ struct query_values post = { 0 }; char* read_post_data() { struct http_query_info info; + char* post_env = getenv("POST"); char* request_method = getenv("REQUEST_METHOD"); char* post_query = NULL, *p_query_read; @@ -43,18 +44,22 @@ char* read_post_data() }; // END Query references - if (request_method && (strcmp("POST", request_method) == 0)) + if ((request_method && (strcmp("POST", request_method) == 0)) || post_env) { - int content_length = atoi(getenv("CONTENT_LENGTH")); + int content_length = post_env ? strlen(post_env) : atoi(getenv("CONTENT_LENGTH")); post_query = malloc(content_length + 1); if (!post_query) { perror("malloc"); return NULL; } - // Read in data - read(STDIN_FILENO, post_query, content_length); - post_query[content_length] = '\0'; + if (post_env) + strcpy(post_query, post_env); + else { + // Read in data + read(STDIN_FILENO, post_query, content_length); + post_query[content_length] = '\0'; + } // For shifting through p_query_read = post_query;