#include #include #include #include "http/response.h" #include "http/header.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 * httpResponseToString(HttpResponse response, char * _string) { HttpMessage message = (HttpMessage)response; char status[4]; string = _string; snprintf(status, 4, "%d", response->status); strcpy(string, message->version); string += strlen(string); *string++ = ' '; strcpy(string, status); string += strlen(string); *string++ = ' '; strcpy(string, response->reason); string += strlen(string); *string++ = '\r'; *string++ = '\n'; twalk(message->header, addHeaderString); *string++ = '\r'; *string++ = '\n'; if (HTTP_MESSAGE_BUFFERED == message->type) { memcpy(string, (message->body).buffer, message->nbody); } return string; } // vim: set ts=4 sw=4: