assorted attempted fixes of things

master
Drake 2 years ago
parent 4d323d55cd
commit 64c38adca5

Binary file not shown.

@ -57,7 +57,6 @@ void* readFileBin(int* len, char* path) {
stat(path, &st);
int length = st.st_size;
*len = length;
printf("%d\n", length);
buf = (void*)malloc(sizeof(int) * (length + 1));
fread(buf, sizeof(int), length, fp);

@ -21,10 +21,11 @@ ReqHeader readReqHeader(int client) {
ReqHeader header;
header.method = malloc(1024);
header.path = malloc(1024);
char* tBuf = malloc(1024);
/*strcpy(header.method, strtok(buf, " "));
strcpy(header.path, strtok(NULL, " "));*/
sprintf(header.method, "%s", strtok(buf, " "));
sprintf(header.path, "%s", strtok(NULL, " "));
sprintf(header.method, "%s", strtok_r(buf, " ", &tBuf));
sprintf(header.path, "%s", strtok_r(NULL, " ", &tBuf));
if (header.path[1] == '\0') {
//strcpy(header.path, "/index.html");
sprintf(header.path, "/index.html");

@ -37,8 +37,8 @@ void *handle(void* arg) {
rawHeader.protocol = request.protocol;
rawHeader.status = 200;
rawHeader.notice = "OK";
int useBinary = getMime(&rawHeader.mime, request.path);
int useBinary = getMime(&rawHeader.mime, request.path);
if (errno == -1) {
rawHeader.status = 404;
rawHeader.notice = "Not Found";
@ -62,9 +62,6 @@ void *handle(void* arg) {
file = readFileBin(&len, request.path);
send(client, file, len, 0);
}
//char* resHeader = malloc(strlen(tmpHeader) + strlen(file) + 1); //= "HTTP/1.1 200 OK\r\n\nHello, world!";
//sprintf(resHeader, "%s%s", (char*)tmpHeader, file);
//send(client, resHeader, strlen(resHeader), 0);
close(client);
return 0;
}

Loading…
Cancel
Save