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