23 #include <sys/types.h>
70 this->current_request =
queueGet(this->parser->queue);
71 this->current_response = NULL;
79 if (NULL == this->current_response) {
80 if (0 == strcmp(
"POST", this->current_request->method) ||
81 0 == strcmp(
"PUT", this->current_request->method))
89 if (0 == strcmp(
"GET", this->current_request->method)) {
90 ConfigValue assets_dir =
93 char asset_path[2048];
95 char html_asset[] =
"/assets/html";
96 char base_asset[] =
"/assets";
97 char main_asset[] =
"/main.html";
102 strcpy(asset_path, (assets_dir->value).string);
104 if (0 == strcmp(
"/", this->current_request->path)) {
107 asset = this->current_request->path;
110 mime_type = strrchr(asset,
'.');
111 if (NULL != mime_type) {
113 mime_type =
getMimeType(mime_type, strlen(mime_type));
116 if (NULL != mime_type &&
117 0 == memcmp(mime_type,
CSTRA(
"text/html"))) {
118 strcat(asset_path, html_asset);
120 strcat(asset_path, base_asset);
123 strcat(asset_path, asset);
124 this->current_response =
129 if (NULL == this->current_response) {
135 delete(this->current_request);
136 queuePut(this->writer->queue, this->current_response);
137 this->current_response = NULL;
141 return this->writer->queue->nmsg;
ConfigValue configGet(Config, const char *, size_t)
void subjectNotify(void *)
ssize_t httpWorkerProcess(HttpWorker this, Stream st)
HttpResponse httpResponse500()
#define CSTRA(val)
Const STRing Argument.
char * getMimeType(const char *, size_t)
HttpMessage httpWorkerGetAsset(HttpWorker, const char *)
ssize_t httpParserParse(void *, Stream)
void queuePut(Queue, void *)
void httpWorkerAddComputedHeader(HttpWorker)
HttpResponse httpResponse404()
void httpWorkerAddCommonHeader(HttpWorker)