diff -r 08adb4f87160 -r cf054cded046 libidav/utils.c --- a/libidav/utils.c Thu Oct 15 15:01:50 2015 +0200 +++ b/libidav/utils.c Thu Oct 15 15:36:26 2015 +0200 @@ -283,6 +283,81 @@ return ret; } +static size_t util_header_callback(char *buffer, size_t size, + size_t nitems, void *data) { + + char *duped; // local variable for string duplicates + + UcxMap *map = (UcxMap*) data; + + // if we get a status line, clear the map and exit + if(size*nitems >= 5 && !strncmp("HTTP/", buffer, 5)) { + ucx_map_free_content(map, free); + ucx_map_clear(map); + return size*nitems; + } + + // if we get the terminating CRLF, just exit + if (size*nitems == 2 && !strncmp("\r\n", buffer, 2)) { + return 2; + } + + + // get header key + size_t s = 0; + do { + s++; + } while(buffer[s] != ':'); + char *value = buffer+s+1; + + // remove trailing spaces + while(isspace(buffer[s-1])) { + s--; + } + + // save key as all lower case + duped = malloc(s); + for(size_t i = 0;i