Server 0.0.1
HTTP/REST server implementation

src/http/response/404.c

Go to the documentation of this file.
00001 
00023 #include <stdlib.h>
00024 #include <string.h>
00025 #include <stdio.h>
00026 #include <sys/types.h>
00027 
00028 #include "class.h"
00029 
00030 #include "http/response.h"
00031 #include "http/message.h"
00032 #include "http/header.h"
00033 
00034 #include "utils/memory.h"
00035 #include "hash.h"
00036 
00037 #define RESP_DATA "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n" \
00038         "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n" \
00039         " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" \
00040         "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n" \
00041         "<head><title>404 - Not Found</title></head>" \
00042         "<body><h1>404 - Not Found</h1></body>" \
00043         "</html>"
00044 
00045 
00046 HttpResponse
00047 httpResponse404()
00048 {
00049         HttpResponse response;
00050         HttpMessage  message;
00051 
00052         response = new(HttpResponse, "HTTP/1.1", 404, "Not Found");
00053         message  = (HttpMessage)response;
00054 
00055         hashAdd(message->header,
00056                         new(HttpHeader, CSTRA("Content-Type"), CSTRA("text/html")));
00057 
00058         message->type  = HTTP_MESSAGE_BUFFERED;
00059         message->nbody = sizeof(RESP_DATA) - 1;
00060         message->body  = malloc(sizeof(RESP_DATA));
00061         memcpy(message->body, RESP_DATA, sizeof(RESP_DATA));
00062 
00063         return response;
00064 }
00065 
00066 // vim: set ts=4 sw=4:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines