Add missing tests (#10008)
thiagoftsm committed
Sep 29, 2020 at 18:21 UTC
effc1eb54773a446770a551cafa771d4c0c022d6
1 file changed
+6
web/server/web_client.c
+6
@@ -814,10 +814,12 @@ static inline char *http_header_parse(struct web_client *w, char *s, int parse_u
814
}
815
}
816
#endif /* NETDATA_WITH_ZLIB */
817
+#ifdef ENABLE_HTTPS
818
else if(hash == hash_forwarded_proto && !strcasecmp(s, "X-Forwarded-Proto")) {
819
if(strcasestr(v, "https"))
820
w->ssl.flags |= NETDATA_SSL_PROXY_HTTPS;
821
}
822
+#endif
823
else if(hash == hash_forwarded_host && !strcasecmp(s, "X-Forwarded-Host")){
824
strncpyz(w->forwarded_host, v, ((size_t)(ve - v) < sizeof(w->server_host)-1 ? (size_t)(ve - v) : sizeof(w->server_host)-1));
825
}
@@ -1352,7 +1354,11 @@ static inline int web_client_switch_host(RRDHOST *host, struct web_client *w, ch
1354
if(!url) { //no delim found
1355
debug(D_WEB_CLIENT, "%llu: URL doesn't end with / generating redirect.", w->id);
1356
char *protocol, *url_host;
1357
+#ifdef ENABLE_HTTPS
1358
protocol = ((w->ssl.conn && !w->ssl.flags) || w->ssl.flags & NETDATA_SSL_PROXY_HTTPS) ? "https" : "http";
1359
+#else
1360
+ protocol = "http";
1361
+#endif
1362
url_host = (!w->forwarded_host[0])?w->server_host:w->forwarded_host;
1363
buffer_sprintf(w->response.header, "Location: %s://%s%s/\r\n", protocol, url_host, w->last_url);
1364
buffer_strcat(w->response.data, "Permanent redirect");