Browse Source

now sending non html data from one of the other folders also works

release0.1.5
Georg Hopp 12 years ago
parent
commit
21abd36396
  1. 0
      assets/other/.keep-me
  2. 11
      src/http/worker.c
  3. 11
      src/http/worker/process.c

0
assets/other/.keep-me

11
src/http/worker.c

@ -60,14 +60,15 @@ httpWorkerCtor(void * _this, va_list * params)
if (NULL != handle) {
char buffer[512];
while (NULL != fgets(buffer, 512, handle)) {
buffer[511] = '\0';
while (NULL != fgets(buffer, 511, handle)) {
char * tmp;
char * key = buffer;
char * value;
size_t nkey;
size_t nvalue;
buffer[511] = '\0';
tmp = memchr(key, ' ', 512);
if (NULL != tmp) {
@ -76,10 +77,14 @@ httpWorkerCtor(void * _this, va_list * params)
nkey = tmp - buffer;
value = tmp + 1;
for (; *value == ' ' && value < buffer+512; value++);
for (; *value == ' ' && value < buffer+511; value++);
nvalue = strlen(value);
if ('\n' == value[nvalue-1]) {
value[nvalue-1] = '\0';
}
hashAdd(this->mime_types,
new(HashValue, key, nkey, value, nvalue));
}

11
src/http/worker/process.c

@ -225,16 +225,25 @@ httpWorkerProcess(HttpWorker this, Stream st)
}
else {
char asset[2048] = "./assets/html";
char html_asset[2048] = "./assets/html";
char base_asset[2048] = "./assets";
char * extension = strrchr(request->path, '.');
char * mime_type = NULL;
char default_mime[] = "application/octet-stream";
char * asset = base_asset;
if (NULL != extension) {
extension++;
mime_type = httpWorkerGetMimeType(this, extension);
}
if (NULL != mime_type &&
0 == memcmp(mime_type, CSTRA("text/html"))) {
asset = html_asset;
}
if (NULL == mime_type) {
mime_type = default_mime;
}

Loading…
Cancel
Save