Revert "attempt to send binary data (for images, etc)"

This reverts commit 3ff8f9a0c6.

that was a remarkably horrible idea wtf
master
Drake 2 years ago
parent 3ff8f9a0c6
commit e2b2b4fe09

Binary file not shown.

Binary file not shown.

@ -4,7 +4,7 @@
#include <string.h>
#include <errno.h>
void* readFile(char* path) {
char* readFile(char* path) {
path++;
if (strlen(path) <= 1) {
printf("/ converted to /index.html\n");
@ -17,13 +17,15 @@ void* readFile(char* path) {
errno = -1;
return "";
}
void* buf = NULL;
char* buf = NULL;
fseek(fp, 0, SEEK_END);
int length = ftell(fp);
rewind(fp);
buf = malloc(sizeof(char) * (length + 1));
buf = (char*)malloc(sizeof(char) * (length + 1));
fread(buf, sizeof(char), length, fp);
buf[length] = '\0';
return buf;
char* tmp = buf;
return tmp;
}

@ -45,7 +45,7 @@ int srv(char* ADDR, int PORT) {
char* tPath = request.path;
char* dot = strrchr(tPath, '.');
void *file = readFile(request.path);
char *file = readFile(request.path);
ResHeader rawHeader;
rawHeader.protocol = request.protocol;
rawHeader.status = 200;
@ -75,9 +75,8 @@ int srv(char* ADDR, int PORT) {
char tmpHeader[1024];
makeHeader(tmpHeader, &rawHeader);
char resHeader[1024]; //= "HTTP/1.1 200 OK\r\n\nHello, world!";
sprintf(resHeader, "%s", (char*)tmpHeader);
sprintf(resHeader, "%s%s", (char*)tmpHeader, file);
send(client, resHeader, strlen(resHeader), 0);
send(client, (void*)(&file), sizeof(file), 0);
close(client);
}
}

Loading…
Cancel
Save