summaryrefslogtreecommitdiffstats
path: root/web/attachments/264173-check_http-PostFromFile.patch
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/264173-check_http-PostFromFile.patch')
-rw-r--r--web/attachments/264173-check_http-PostFromFile.patch98
1 files changed, 98 insertions, 0 deletions
diff --git a/web/attachments/264173-check_http-PostFromFile.patch b/web/attachments/264173-check_http-PostFromFile.patch
new file mode 100644
index 0000000..2fe2102
--- /dev/null
+++ b/web/attachments/264173-check_http-PostFromFile.patch
@@ -0,0 +1,98 @@
1--- check_http.c.orig 2008-01-29 10:58:01.000000000 -0500
2+++ check_http.c 2008-01-29 11:01:47.000000000 -0500
3@@ -122,6 +122,7 @@
4 int max_depth = 15;
5 char *http_method;
6 char *http_post_data;
7+char *http_post_datafile;
8 char *http_content_type;
9 char buffer[MAX_INPUT_BUFFER];
10
11@@ -175,6 +176,9 @@
12 {
13 int c = 1;
14 char *p;
15+ FILE *fp;
16+ char input_buffer[MAX_INPUT_BUFFER];
17+ int first;
18
19 enum {
20 INVERT_REGEX = CHAR_MAX + 1
21@@ -187,6 +191,7 @@
22 {"nohtml", no_argument, 0, 'n'},
23 {"ssl", no_argument, 0, 'S'},
24 {"post", required_argument, 0, 'P'},
25+ {"postfile", required_argument, 0, 'F'},
26 {"IP-address", required_argument, 0, 'I'},
27 {"url", required_argument, 0, 'u'},
28 {"port", required_argument, 0, 'p'},
29@@ -228,7 +233,7 @@
30 }
31
32 while (1) {
33- c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:T:I:a:e:p:s:R:r:u:f:C:nlLSm:M:N", longopts, &option);
34+ c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:F:T:I:a:e:p:s:R:r:u:f:C:nlLSm:M:N", longopts, &option);
35 if (c == -1 || c == EOF)
36 break;
37
38@@ -349,6 +354,11 @@
39 http_method = strdup("POST");
40 http_post_data = strdup (optarg);
41 break;
42+ case 'F': /* HTTP POST data from file in URL encoded format */
43+ if (http_method || http_post_datafile) break;
44+ http_method = strdup("POST");
45+ http_post_datafile = strdup (optarg);
46+ break;
47 case 's': /* string or substring */
48 strncpy (string_expect, optarg, MAX_INPUT_BUFFER - 1);
49 string_expect[MAX_INPUT_BUFFER - 1] = 0;
50@@ -439,6 +449,30 @@
51 }
52
53 c = optind;
54+
55+ /* If user asked to read POST data from file, check for file existence then read content */
56+
57+ if (http_post_datafile != NULL) {
58+ fp = fopen(http_post_datafile,"r");
59+ if (fp == NULL)
60+ usage4 (_("Unable to open POST data file\n"));
61+
62+ first=1;
63+ while (fgets(input_buffer,MAX_INPUT_BUFFER,fp)) {
64+ input_buffer[strlen(input_buffer)-1] = '\0'; /* strip newline */
65+ if (first == 1) {
66+ first=0;
67+ asprintf (&http_post_data, "%s\r\n", input_buffer);
68+ } else {
69+ asprintf (&http_post_data, "%s%s\r\n", http_post_data, input_buffer);
70+ }
71+ }
72+
73+ fclose(fp);
74+ }
75+
76+ /* End of POST data file addition */
77+
78
79 if (server_address == NULL && c < argc)
80 server_address = strdup (argv[c++]);
81@@ -1265,6 +1299,8 @@
82 printf (" %s\n", _("URL to GET or POST (default: /)"));
83 printf (" %s\n", "-P, --post=STRING");
84 printf (" %s\n", _("URL encoded http POST data"));
85+ printf (" %s\n", "-F, --postfile=PATH");
86+ printf (" %s\n", _("file with URL-encoded http POST data"));
87 printf (" %s\n", "-N, --no-body");
88 printf (" %s\n", _("Don't wait for document body: stop reading after headers."));
89 printf (" %s\n", _("(Note that this still does an HTTP GET or POST, not a HEAD.)"));
90@@ -1341,7 +1377,7 @@
91 printf (" %s -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>]\n",progname);
92 printf (" [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L]\n");
93 printf (" [-a auth] [-f <ok | warn | critcal | follow>] [-e <expect>]\n");
94- printf (" [-s string] [-l] [-r <regex> | -R <case-insensitive regex>] [-P string]\n");
95+ printf (" [-s string] [-l] [-r <regex> | -R <case-insensitive regex>] [-P string | -F file]\n");
96 printf (" [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>] [-A string]\n");
97 printf (" [-k string] [-S] [-C <age>] [-T <content-type>]\n");
98 }