Created
December 19, 2021 15:27
-
-
Save angeloped/43a8add2bf466eb3968f99df0b2b96fa to your computer and use it in GitHub Desktop.
Strip HTTP header in C language.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const char* pattern = "\r\n\r\n"; | |
const char* patp = pattern; | |
while ((numbytes = recv(socket_file_descriptor, buf, MAXDATASIZE - 1, 0)) > 0) { | |
for (int i = 0; i < numbytes; i++) { | |
if (*patp == 0) { | |
fwrite(buf + i, 1, numbytes - i, fp); | |
break; | |
} | |
else if (buf[i] == *patp) ++patp; | |
else patp = pattern; | |
} | |
/* This memset isn't really necessary */ | |
memset(buf, 0, MAXDATASIZE); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment