0

I'm stuck on pset6. I keep getting error 404 and cannot figure out what is wrong. Please help.

        // TODO: concatenate root and absolute-path
        char *a;
        char *b;
        if (strchr(line, 63) != NULL)
        {
            a = strchr(line, 47);
            b = strchr(line, 63)-1;
        }
        else
        {
            a = strchr(line, 47);
            b = strrchr(line, 32)-1;
        } 
        char path[b-a-1+strlen(root)+1];
        strcpy(path, root);
        strncat(path, a, b-a);

        // TODO: ensure path exists
        if (access(path, F_OK)!=0)
        {
            error(404);
            continue;
        }
  • Please also add the lines of code that contain the declarations and assignments of root. Also don't use the ASCII numeric values. You don't have to and it makes your code much more unreadable. – ChrisG Jul 18 '15 at 6:44
  • Hey, the root was defined by them, I didn't write that code so it is definitely correct. I want to know if what I am doing here is correct though. I tried with characters but there was some glitch my code wasn't compiling! line is the phrase given. it goes like this, example: GET /hello.html HTTP/1.1 – Sandeep Chowdary Jul 19 '15 at 7:15

You must log in to answer this question.

Browse other questions tagged .