I can't figure out what is wrong with my code, and I don't know where the issue is. I have tried to figure it out by putting printf
calls everywhere, and it appears that my parse
function works as intended, because printing out abs_path
right before the return true
at the end of the function gives me a correct path, i.e. /
for the homepage.
However, right after that (before the urldecode
function), abs_path
gets reset to nothing (i.e. ""
), resulting in an endless redirect, because urldecode
gets passed an empty string and wants to redirect to /
, which then again becomes an empty string when it gets passed into urldecode
.
if (parse(line, abs_path, query)) // printf call inside of parse prints "/"
{
// debug
printf("abs_path before urldecode = %s\n", abs_path); // prints ""
This is my parse
function (just the last few lines):
bool parse(const char* line, char* abs_path, char* query)
{
// code that implements parse
// debug
printf("abs_path before return true = %s\n", abs_path); // prints "/"
return true;
}
Does anyone have any idea what could be causing this?