I've implemented load and indexes and the website seems to work ok. I say ok because it prints out hello, hello, world when I access hello.php, and fails pretty much all the checks in the second check50 except "Requesting /test redirects to /test/"

I've attached my load and indexes functions below, can someone help?

bool load(FILE* file, BYTE** content, size_t* length)
    //initialize content and length as NULL
    *content = NULL;
    *length = 0;
    char buffer[BYTES];
    ssize_t num_bytes = 0;

    while((num_bytes = fread(buffer, 1, BYTES, file)) > 0)
        if ((*content = realloc(*content, *length + num_bytes)) == NULL)
            return false;
        memcpy(*content + *length, buffer, num_bytes);
        *length += num_bytes;

    return true;

And indexes:

char* indexes(const char* path)
    // TODO
    //path_p to store index.php appended path
    char* path_p = malloc(strlen(path) + 10);
    strcpy(path_p, path);
    path_p = strcat(path_p, "index.php");
    path_p[strlen(path) + 9] = '\0';

    //path_h to store index.html appended path
    char* path_h = malloc(strlen(path) + 11);
    strcpy(path_h, path);
    path_h = strcat(path_h, "index.html");
    path_h[strlen(path) + 10] = '\0';

    if (access(path_p, F_OK) == 0)
        return path_p;
    else if (access(path_h, F_OK) == 0)
        return path_h;
    return NULL;

Any help is greatly appreciated, thanks!

1 Answer 1


Turns out I read the spec wrong and was returning the wrong string in my lookup function...so silly. All is well now!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .