get_header.c 813 Bytes
#include <stdlib.h>
#include <string.h>
#include <search.h>
#include <ctype.h>
#include <stdio.h>

#include "class.h"
#include "interface/class.h"
#include "http/header.h"
#include "http/message.h"
#include "http/request/parser.h"
#include "ringbuffer.h"

ssize_t
httpRequestParserGetHeader(HttpRequestParser this, char * cr)
{
	HttpMessage message = (HttpMessage)this->cur_request;
	char * value;
	char * name = this->buffer->buffer + this->buffer->bstart;
	size_t len = cr - name;

	value = memchr(
			this->buffer->buffer + this->buffer->bstart,
			':', len);

	if (NULL == value) {
		return -1;
	}

	*cr        = 0;
	*(value++) = 0;
	while(' ' == *value) value++;

	httpHeaderAdd(&(message->header), new(HttpHeader, name, value));

	return 1; //* @TODO: return something useful here
}

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