header_to_string.c 691 Bytes
#include <search.h>
#include <string.h>
#include <stdio.h>

#include "http/response.h"
#include "http/header.h"
#include "interface/http_intro.h"

static char * string;

void
addHeaderString(const void * node, const VISIT which, const int depth)
{
	if (endorder == which || leaf == which) {
		string += httpHeaderToString(*(HttpHeader *)node, string);
		*string++ = '\r';
		*string++ = '\n';
	}
}

char *
httpMessageHeaderToString(HttpMessage response, char * _string)
{
	HttpMessage message = (HttpMessage)response;

	string = httpIntroToString(response, _string);

	twalk(message->header, addHeaderString);

	*string++ = '\r';
	*string++ = '\n';

	return string;
}

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