You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.0 KiB
58 lines
1.0 KiB
#include <search.h>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
|
|
#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:
|