Skip to content

Instantly share code, notes, and snippets.

@itrobotics
Created September 9, 2022 03:13
Show Gist options
  • Save itrobotics/61445305d19c50c2e77d7c9dc66dff7f to your computer and use it in GitHub Desktop.
Save itrobotics/61445305d19c50c2e77d7c9dc66dff7f to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
int main ()
{
char method_str[]="GET /doc/test.html HTTP/1.1 \r\n";
char *url;
char *protocol;
char *end;
url=strpbrk(method_str," \t\n\r") ;
printf("%s\n",url);
*url++='\0';
url += strspn(url, " \t\n\r");
protocol = strpbrk(url, " \t\n\r");
*protocol++='\0';
protocol += strspn(protocol, " \t\n\r");
end = strpbrk(protocol, " \t\n\r");
*end++='\0';
printf("%s\n",method_str);
printf("%s\n",url);
printf("%s\n",protocol);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment