summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Beier <dontmind@freeshell.org>2016-11-25 15:07:48 +0100
committerChristian Beier <dontmind@freeshell.org>2016-11-25 15:07:48 +0100
commit65106d39627499ace4f1ed8701d3ab6c7f97f56f (patch)
tree8fc8fed41eb6c3c1eeaac836000852e6944f1c10
parentce848322ecb56c1d62b01fca21aaf5caeb917e97 (diff)
downloadlibtdevnc-65106d39.tar.gz
libtdevnc-65106d39.zip
httpd: rework mime type handling to recognise more types
-rw-r--r--libvncserver/httpd.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/libvncserver/httpd.c b/libvncserver/httpd.c
index 236ab3e..fe7ac22 100644
--- a/libvncserver/httpd.c
+++ b/libvncserver/httpd.c
@@ -81,9 +81,7 @@
"<HEAD><TITLE>Invalid Request</TITLE></HEAD>\n" \
"<BODY><H1>Invalid request</H1></BODY>\n"
-#define OK_STR "HTTP/1.0 200 OK\r\nConnection: close\r\n\r\n"
-#define OK_STR_HTML "HTTP/1.0 200 OK\r\nConnection: close\r\nContent-Type: text/html\r\n\r\n"
-
+#define OK_STR "HTTP/1.0 200 OK\r\nConnection: close\r\n"
static void httpProcessInput(rfbScreenInfoPtr screen);
@@ -454,10 +452,18 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
return;
}
- if(performSubstitutions) /* is the 'index.vnc' file */
- rfbWriteExact(&cl, OK_STR_HTML, strlen(OK_STR_HTML));
- else
- rfbWriteExact(&cl, OK_STR, strlen(OK_STR));
+ rfbWriteExact(&cl, OK_STR, strlen(OK_STR));
+ char *ext = strrchr(fname, '.');
+ char *contentType = "";
+ if(ext && strcasecmp(ext, ".vnc") == 0)
+ contentType = "Content-Type: text/html\r\n";
+ else if(ext && strcasecmp(ext, ".css") == 0)
+ contentType = "Content-Type: text/css\r\n";
+ else if(ext && strcasecmp(ext, ".svg") == 0)
+ contentType = "Content-Type: image/svg+xml\r\n";
+ rfbWriteExact(&cl, contentType, strlen(contentType));
+ /* end the header */
+ rfbWriteExact(&cl, "\r\n", 4);
while (1) {
int n = fread(buf, 1, BUF_SIZE-1, fd);