httpRespond(session_fd, "\n");
}
+int httpStringOutByType(int session_fd, char* str, const char* type)
+{
+ //Good header
+ httpRespond(session_fd, "HTTP/1.1 200 OK\n");
+ httpRespond(session_fd, HTTP_SERVER);
+
+ int strSize = strlen(str);
+ //Spit out file content length part of the HTTP message
+ const char *contentLengthTemplate = "Access-Control-Allow-Origin: *\nContent-Type: %s\nContent-Length: %i\n\n";
+ int contentLengthLen = snprintf(NULL, 0, contentLengthTemplate, type, strSize);
+ char* contentLength = malloc(contentLengthLen + 1);
+ sprintf(contentLength, contentLengthTemplate, strSize);
+ httpRespond(session_fd, contentLength);
+ free(contentLength);
+
+ httpRespond(session_fd, str);
+ httpRespond(session_fd, "\n");
+}
+
void httpRequest(int session_fd, char** str, int* strlen)
{
int flags = fcntl(session_fd, F_GETFL, 0);
uint8_t* frontend = malloc(sizeof(FAVICON) + 1);
memcpy(frontend, FAVICON, sizeof(FAVICON));
frontend[sizeof(FAVICON)] = 0;
- httpStringOut(session_fd, frontend);
+ httpStringOutByType(session_fd, frontend, "image/x-icon");
free(frontend);
}
else