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
|
--- check_http.c.orig 2010-07-27 16:47:16.000000000 -0400
+++ check_http.c 2011-04-05 12:02:56.000000000 -0400
@@ -94,6 +94,7 @@
char server_type[6] = "http";
char *server_address;
char *host_name;
+char *host_header;
char *server_url;
char *user_agent;
int server_url_length;
@@ -346,6 +347,13 @@
case 'u': /* URL path */
server_url = strdup (optarg);
server_url_length = strlen (server_url);
+ // Also set HTTP host header
+ char delim[] = "/";
+ if (!strncmp(optarg, "http://", 7) ) {
+ host_header=strdup(strtok(optarg+7, delim));
+ } else if (!strncmp(optarg, "https://", 8) ) {
+ host_header=strdup(strtok(optarg+8, delim));
+ }
break;
case 'p': /* Server port */
if (!is_intnonneg (optarg))
@@ -823,7 +831,10 @@
asprintf (&buf, "%sConnection: close\r\n", buf);
/* optionally send the host header info */
- if (host_name) {
+ if (!host_header) {
+ host_header=strdup(host_name);
+ }
+ if (host_header) {
/*
* Specify the port only if we're using a non-default port (see RFC 2616,
* 14.23). Some server applications/configurations cause trouble if the
@@ -831,9 +842,9 @@
*/
if ((use_ssl == FALSE && server_port == HTTP_PORT) ||
(use_ssl == TRUE && server_port == HTTPS_PORT))
- asprintf (&buf, "%sHost: %s\r\n", buf, host_name);
+ asprintf (&buf, "%sHost: %s\r\n", buf, host_header);
else
- asprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, server_port);
+ asprintf (&buf, "%sHost: %s:%d\r\n", buf, host_header, server_port);
}
/* optionally send any other header tag */
|