On line 822-823 (as of commit 83d65de), the following lines of code result in a segmentation fault:
char *tok = NULL;
for (tok = strtok_r(NULL, "\r\n", &bufptr); tok; tok = strtok_r(NULL, "\r\n", &bufptr)) {
I think this happens because you're not supposed to call strtok_r() with NULL as the first argument until after the first time. I'm not sure if you meant to pass 'url' or something else.
Edit: If I use 'url', it chops off everything after 'http', so that's not right.
Edit 2: 'path' seems to give a sensible result in a quick test case. Not sure if it works completely as intended or not.