From 8f54442c68cf5bfaffc33b8e618462e82771478b Mon Sep 17 00:00:00 2001 From: Eric Wunderlin Date: Mon, 11 Apr 2016 12:52:02 -0500 Subject: Added ability to correctly check redirects with reference format //test.server.com/folder Referenced redirect of the format //www.server.com/folder would result in check_http trying to contact http://hostname:80//www.server.com/folder instead of http://www.server.com/folder. Referenced redirect of this format is listed in rfc3986 ( https://tools.ietf.org/html/rfc3986 ). It should work as expected now. --- plugins/check_http.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'plugins/check_http.c') diff --git a/plugins/check_http.c b/plugins/check_http.c index f8ec853b..36f3b253 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c @@ -1364,6 +1364,9 @@ check_http (void) #define HD3 URI_HTTP "://" URI_HOST ":" URI_PORT #define HD4 URI_HTTP "://" URI_HOST #define HD5 URI_PATH +/* relative reference redirect like //www.site.org/test https://tools.ietf.org/html/rfc3986 */ +#define HD6 "//" URI_HOST "/" URI_PATH + void redir (char *pos, char *status_line) @@ -1440,6 +1443,21 @@ redir (char *pos, char *status_line) use_ssl = server_type_check (type); i = server_port_check (use_ssl); } + else if (sscanf (pos, HD6, addr, url) == 2) { + //get type from + if(use_ssl){ + //i = server_port_check (use_ssl); + strcpy (type,"https"); + } + //else if(sscanf(server_url,URI_HTTP,type)==1 ){ + //} + else{ + strcpy (type, server_type); + } + xasprintf (&url, "/%s", url); + use_ssl = server_type_check (type); + i = server_port_check (use_ssl); + } /* URI_PATH */ else if (sscanf (pos, HD5, url) == 1) { -- cgit v1.2.3-74-g34f1 From d57d2b0bdda192dc50e17ebeb8becfe249c3f8e3 Mon Sep 17 00:00:00 2001 From: Eric Wunderlin Date: Tue, 12 Apr 2016 09:00:08 -0500 Subject: Remove unused code --- plugins/check_http.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'plugins/check_http.c') diff --git a/plugins/check_http.c b/plugins/check_http.c index 36f3b253..59755acd 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c @@ -1444,13 +1444,9 @@ redir (char *pos, char *status_line) i = server_port_check (use_ssl); } else if (sscanf (pos, HD6, addr, url) == 2) { - //get type from if(use_ssl){ - //i = server_port_check (use_ssl); strcpy (type,"https"); } - //else if(sscanf(server_url,URI_HTTP,type)==1 ){ - //} else{ strcpy (type, server_type); } -- cgit v1.2.3-74-g34f1 From e2e405596a070ec3b830696ecf574ee3a243c7b1 Mon Sep 17 00:00:00 2001 From: "John C. Frickson" Date: Mon, 21 Nov 2016 22:40:39 +0100 Subject: I had to make a couple of small changes. --- plugins/check_http.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'plugins/check_http.c') diff --git a/plugins/check_http.c b/plugins/check_http.c index 59755acd..fb38bc5b 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c @@ -1363,10 +1363,9 @@ check_http (void) #define HD2 URI_HTTP "://" URI_HOST "/" URI_PATH #define HD3 URI_HTTP "://" URI_HOST ":" URI_PORT #define HD4 URI_HTTP "://" URI_HOST -#define HD5 URI_PATH /* relative reference redirect like //www.site.org/test https://tools.ietf.org/html/rfc3986 */ -#define HD6 "//" URI_HOST "/" URI_PATH - +#define HD5 "//" URI_HOST "/" URI_PATH +#define HD5 URI_PATH void redir (char *pos, char *status_line) @@ -1443,7 +1442,8 @@ redir (char *pos, char *status_line) use_ssl = server_type_check (type); i = server_port_check (use_ssl); } - else if (sscanf (pos, HD6, addr, url) == 2) { + /* URI_HTTP, URI_HOST, URI_PATH */ + else if (sscanf (pos, HD5, addr, url) == 2) { if(use_ssl){ strcpy (type,"https"); } @@ -1456,7 +1456,7 @@ redir (char *pos, char *status_line) } /* URI_PATH */ - else if (sscanf (pos, HD5, url) == 1) { + else if (sscanf (pos, HD6, url) == 1) { /* relative url */ if ((url[0] != '/')) { if ((x = strrchr(server_url, '/'))) -- cgit v1.2.3-74-g34f1 From 80872917294340a1e399b8a100c5a81c4f719220 Mon Sep 17 00:00:00 2001 From: Jan Wagner Date: Sat, 31 Dec 2016 13:57:44 +0100 Subject: check_http: Fix HD6 definition --- plugins/check_http.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/check_http.c') diff --git a/plugins/check_http.c b/plugins/check_http.c index fb38bc5b..ff39c591 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c @@ -1365,7 +1365,7 @@ check_http (void) #define HD4 URI_HTTP "://" URI_HOST /* relative reference redirect like //www.site.org/test https://tools.ietf.org/html/rfc3986 */ #define HD5 "//" URI_HOST "/" URI_PATH -#define HD5 URI_PATH +#define HD6 URI_PATH void redir (char *pos, char *status_line) -- cgit v1.2.3-74-g34f1 From edc84e5d669089fa3f047dc52740679e7cb58fc1 Mon Sep 17 00:00:00 2001 From: Lorenz <12514511+RincewindsHat@users.noreply.github.com> Date: Sat, 5 Nov 2022 13:59:45 +0100 Subject: Remove superflous CRLF in HTTP-Requests in check_http (#1798) * Remove superflous CRLF in HTTP-Requests in check_http --- plugins/check_http.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'plugins/check_http.c') diff --git a/plugins/check_http.c b/plugins/check_http.c index ff39c591..41d47816 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c @@ -1070,9 +1070,8 @@ check_http (void) } xasprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, (int)strlen (http_post_data)); - xasprintf (&buf, "%s%s%s", buf, http_post_data, CRLF); - } - else { + xasprintf (&buf, "%s%s", buf, http_post_data); + } else { /* or just a newline so the server knows we're done with the request */ xasprintf (&buf, "%s%s", buf, CRLF); } -- cgit v1.2.3-74-g34f1