get_request_line.c
648 Bytes
#include <stdlib.h>
#include <string.h>
#include "http/request.h"
void
httpRequestParserGetRequestLine(HttpRequest request, char * line)
{
char * method, * uri, * version;
method = line;
uri = strchr(line, ' ');
*uri++ = 0;
for (; *uri == ' ' && *uri != 0; uri++);
version = strchr(uri, ' ');
*version++ = 0;
for (; *version == ' ' && *version != 0; version++);
request->method = malloc(strlen(method) + 1);
strcpy(request->method, method);
request->uri = malloc(strlen(uri) + 1);
strcpy(request->uri, uri);
request->version = malloc(strlen(version) + 1);
strcpy(request->version, method);
}
// vim: set ts=4 sw=4: