get_request_line.c 693 Bytes
#include <stdlib.h>
#include <string.h>

#include "http/request.h"


void
httpRequestParserGetRequestLine(HttpRequest request, char * line)
{
	HttpMessage message = (HttpMessage)request;
	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);
	message->version = malloc(strlen(version) + 1);
	strcpy(message->version, method);
}

// vim: set ts=4 sw=4: