]> arthur.barton.de Git - netdata.git/commitdiff
fix for case sensitive HTTP headers and gzip detection
authorCosta Tsaousis <costa@tsaousis.gr>
Fri, 13 May 2016 00:37:52 +0000 (03:37 +0300)
committerCosta Tsaousis <costa@tsaousis.gr>
Fri, 13 May 2016 00:37:52 +0000 (03:37 +0300)
src/registry.c
src/web_client.c

index 932ee5af236121d9e38f029cc8dc58d2ba28e743..4e88dc6546c088a72ddec85b0fcf4a7ee2f56250 100644 (file)
@@ -1651,7 +1651,7 @@ int registry_init(void) {
        registry.save_registry_every_entries = config_get_number("registry", "registry save db every new entries", 1000000);
        registry.persons_expiration = config_get_number("registry", "registry expire idle persons days", 365) * 86400;
        registry.registry_domain = config_get("registry", "registry domain", "");
-       registry.registry_to_announce = config_get("registry", "registry to announce", "https://registry.my-netdata.io");
+       registry.registry_to_announce = config_get("registry", "registry to announce", "//registry.my-netdata.io");
        registry.hostname = config_get("registry", "registry hostname", config_get("global", "hostname", hostname));
 
        registry.max_url_length = config_get_number("registry", "max URL length", 1024);
index 5cba375d4b330ebd3c90dea9ef5ad07df968045e..05647a28c0a94328c2bd19ef868d9b76a0561ea6 100644 (file)
@@ -1185,14 +1185,6 @@ cleanup:
 
 
 static inline char *http_header_parse(struct web_client *w, char *s) {
-       static uint32_t connection_hash = 0, accept_encoding_hash = 0, origin_hash = 0;
-
-       if(unlikely(connection_hash == 0)) {
-               connection_hash = simple_hash("Connection");
-               accept_encoding_hash = simple_hash("Accept-Encoding");
-               origin_hash = simple_hash("Origin");
-       }
-
        char *e = s;
 
        // find the :
@@ -1201,7 +1193,6 @@ static inline char *http_header_parse(struct web_client *w, char *s) {
 
        // get the name
        *e = '\0';
-       uint32_t hash = simple_hash(s);
 
        // find the value
        char *v, *ve;
@@ -1217,17 +1208,20 @@ static inline char *http_header_parse(struct web_client *w, char *s) {
        // terminate the value
        *ve = '\0';
 
-       if(hash == origin_hash && !strcmp(s, "Origin")) {
+       // fprintf(stderr, "HEADER: '%s' = '%s'\n", s, v);
+
+       if(!strcasecmp(s, "Origin")) {
                strncpy(w->origin, v, ORIGIN_MAX);
        }
-       else if(hash == connection_hash && !strcmp(s, "Connection")) {
+       else if(!strcasecmp(s, "Connection")) {
                if(!strcasestr(v, "keep-alive"))
                        w->keepalive = 1;
        }
 #ifdef NETDATA_WITH_ZLIB
-       else if(hash == accept_encoding_hash && !strcmp(s, "Accept-Encoding")) {
-               if(web_enable_gzip && !strcasestr(v, "gzip"))
+       else if(!strcasecmp(s, "Accept-Encoding")) {
+               if(web_enable_gzip && strcasestr(v, "gzip")) {
                        w->enable_gzip = 1;
+               }
        }
 #endif /* NETDATA_WITH_ZLIB */
 
@@ -1675,7 +1669,7 @@ void web_client_process(struct web_client *w) {
        if(w->mode == WEB_CLIENT_MODE_OPTIONS) {
                buffer_strcat(w->response.header_output,
                        "Access-Control-Allow-Methods: GET, OPTIONS\r\n"
-                       "Access-Control-Allow-Headers: Accept, X-Requested-With, Content-Type, Cookie\r\n"
+                       "Access-Control-Allow-Headers: accept, x-requested-with, origin, content-type, cookie\r\n"
                        "Access-Control-Max-Age: 1209600\r\n" // 86400 * 14
                        );
        }