From 5756b133f737642e2bb3c9a319b101c0ac23723e Mon Sep 17 00:00:00 2001 From: Christian Beier Date: Thu, 6 Oct 2011 14:29:06 +0200 Subject: httpd: fix sending of binary data such as images. We do this simply by omitting the content-type and let the browser decide upon the mime-type of the sent file. Only exception is 'index.vnc', where we do set the content-type since some browsers fail to detect it's html when it's ending in '.vnc' Also, remove superfluous #defines. We close the connection always. --- libvncserver/httpd.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/libvncserver/httpd.c b/libvncserver/httpd.c index 83fc520..3252fc6 100644 --- a/libvncserver/httpd.c +++ b/libvncserver/httpd.c @@ -59,20 +59,6 @@ #include #endif -#define connection_close -#ifndef connection_close - -#define NOT_FOUND_STR "HTTP/1.0 404 Not found\r\n\r\n" \ - "File Not Found\n" \ - "

File Not Found

\n" - -#define INVALID_REQUEST_STR "HTTP/1.0 400 Invalid Request\r\n\r\n" \ - "Invalid Request\n" \ - "

Invalid request

\n" - -#define OK_STR "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n" - -#else #define NOT_FOUND_STR "HTTP/1.0 404 Not found\r\nConnection: close\r\n\r\n" \ "File Not Found\n" \ @@ -82,9 +68,10 @@ "Invalid Request\n" \ "

Invalid request

\n" -#define OK_STR "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\r\n" +#define OK_STR_HTML "HTTP/1.0 200 OK\r\nConnection: close\r\nContent-Type: text/html\r\n\r\n" + -#endif static void httpProcessInput(rfbScreenInfoPtr screen); static rfbBool compareAndSkip(char **ptr, const char *str); @@ -386,7 +373,10 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen) return; } - rfbWriteExact(&cl, OK_STR, strlen(OK_STR)); + if(performSubstitutions) /* is the 'index.vnc' file */ + rfbWriteExact(&cl, OK_STR_HTML, strlen(OK_STR_HTML)); + else + rfbWriteExact(&cl, OK_STR, strlen(OK_STR)); while (1) { int n = fread(buf, 1, BUF_SIZE-1, fd); -- cgit v1.2.1