|
Server 0.0.1
HTTP/REST server implementation
|
00001 00023 #include <stdlib.h> 00024 #include <string.h> 00025 #include <stdio.h> 00026 #include <time.h> 00027 #include <sys/types.h> 00028 00029 #include "class.h" 00030 00031 #include "http/response.h" 00032 #include "http/message.h" 00033 #include "http/header.h" 00034 00035 #include "utils/memory.h" 00036 #include "hash.h" 00037 00038 #define RESP_DATA "<form action=\"/me/\" method=\"POST\">" \ 00039 "<input name=\"username\" type=\"text\" />" \ 00040 "<input type=\"submit\">" \ 00041 "</form>" 00042 00043 HttpResponse 00044 httpResponseLoginForm() 00045 { 00046 HttpResponse response; 00047 HttpMessage message; 00048 00049 response = new(HttpResponse, "HTTP/1.1", 200, "OK"); 00050 message = (HttpMessage)response; 00051 00052 hashAdd(message->header, 00053 new(HttpHeader, CSTRA("Content-Type"), CSTRA("text/html"))); 00054 00055 message->type = HTTP_MESSAGE_BUFFERED; 00056 00057 message->nbody = sizeof(RESP_DATA)-1; 00058 message->body = malloc(message->nbody); 00059 memcpy(message->body, RESP_DATA, message->nbody); 00060 00061 return response; 00062 } 00063 00064 // vim: set ts=4 sw=4: