I'm new to C specifically and I'm trying to check some strings.
The following is my code, commented to indicate the issues that I don't understand why they are occuring:
if (strstr(recBuff, "GET / HTTP/1.0\r\n\r\n") != NULL)
//Send HTTP/1.0 200
//This gets recognised fine
else if (strstr(recBuff, "GET / HTTP/1.0\r\r") != NULL)
//Send HTTP/1.0 200
//This gets recognised fine
else if (strstr(recBuff, "GET / HTTP/1.0\r\n") != NULL)
//Do something else
//This never gets picked up, and instead goes to the final else...
else
//HTTP/1.0 404
//Etc
I guess my question is why is strstr picking up \r\n\r\n
and acting on it, but just \r\n
by itself goes through all the way until the final else? There's an else for \r\n\r\n
that works, but the else for a single \r\n
doesn't work for a single \r\n
.
TL;DR "GET / HTTP/1.0\r\n\r\n"
gets picked up, but "GET / HTTP/1.0\r\n"
doesn't.