This declaration char* request = "";
basically makes request a const char*
, and as such is immutable. You should not "set" it to "", rather it needs to have some memory allocated before anything is copied into it.
Similarly, this line requestHttpAndTail[i] = '\0';
fails because requeHttpAndTail is a pointer into line's memory, line is a const char* and thus immutable.
And beware, this abs_path = request;
is a slippery slope. Assuming request is a locally allocated variable, it'sits memory will be destroyed when program control returns to main, leaving abs_path, well, not what you expect.
Notice how abs_path and query are declared in server. You would create a much closer repro case if p and q were declared similarly. (Besides the fact that as written, they are immutable).