1
0
mirror of https://github.com/gophernicus/gophernicus.git synced 2024-11-03 04:27:17 -05:00

Merge pull request #67 from augfab/disable_http_response

Add option `-nH` to disable HTTP response to HTTP GET/POST requests (#66)
This commit is contained in:
fosslinux 2020-04-01 20:44:55 +00:00 committed by GitHub
commit 394176e222
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 2 deletions

View File

@ -58,6 +58,7 @@ much more. It is fully FOSS, and licensed under the BSD 2-Clause license.
-np Disable HAproxy proxy protocol
-nx Disable execution of gophermaps and scripts
-nu Disable personal gopherspaces
-nH Disable HTTP response to HTTP GET/POST requests.
-d Debug output in syslog and /server-status
-v Display version number and build date

View File

@ -475,6 +475,7 @@ void init_state(state *st)
st->opt_proxy = TRUE;
st->opt_exec = TRUE;
st->opt_personal_spaces = TRUE;
st->opt_http_requests = TRUE;
st->debug = FALSE;
/* Load default suffix -> filetype mappings */
@ -720,8 +721,9 @@ get_selector:
}
/* Convert HTTP request to gopher (respond using headerless HTTP/0.9) */
if (sstrncmp(selector, "GET ") == MATCH ||
sstrncmp(selector, "POST ") == MATCH ) {
if (st.opt_http_requests && (
sstrncmp(selector, "GET ") == MATCH ||
sstrncmp(selector, "POST ") == MATCH)) {
if ((c = strchr(selector, ' '))) sstrlcpy(selector, c + 1);
if ((c = strchr(selector, ' '))) *c = '\0';

View File

@ -369,6 +369,7 @@ typedef struct {
char opt_proxy;
char opt_exec;
char opt_personal_spaces;
char opt_http_requests;
char debug;
} state;

View File

@ -157,6 +157,7 @@ void parse_args(state *st, int argc, char *argv[])
if (*optarg == 'p') { st->opt_proxy = FALSE; break; }
if (*optarg == 'x') { st->opt_exec = FALSE; break; }
if (*optarg == 'u') { st->opt_personal_spaces = FALSE; break; }
if (*optarg == 'H') { st->opt_http_requests = FALSE; break; }
break;
case 'd': st->debug = TRUE; break;