From edbd5ab8d4512a7adb089f3e4791e54523748253 Mon Sep 17 00:00:00 2001 From: Christian Beier Date: Tue, 4 Oct 2011 18:26:48 +0200 Subject: Add noVNC HTML5 client connect possibility to our http server. Pure JavaScript, no Java plugin required anymore! (But a recent browser...) --- libvncserver/httpd.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'libvncserver') diff --git a/libvncserver/httpd.c b/libvncserver/httpd.c index ad2a51b..83fc520 100644 --- a/libvncserver/httpd.c +++ b/libvncserver/httpd.c @@ -346,12 +346,6 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen) return; } - if (strchr(fname+1, '/') != NULL) { - rfbErr("httpd: asking for file in other directory\n"); - rfbWriteExact(&cl, NOT_FOUND_STR, strlen(NOT_FOUND_STR)); - httpCloseSock(rfbScreen); - return; - } getpeername(rfbScreen->httpSock, (struct sockaddr *)&addr, &addrlen); rfbLog("httpd: get '%s' for %s\n", fname+1, @@ -447,6 +441,10 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen) sprintf(str, "%d", rfbScreen->port); rfbWriteExact(&cl, str, strlen(str)); + } else if (compareAndSkip(&ptr, "$HOST")) { + + rfbWriteExact(&cl, rfbScreen->thisHost, strlen(rfbScreen->thisHost)); + } else if (compareAndSkip(&ptr, "$DESKTOP")) { rfbWriteExact(&cl, rfbScreen->desktopName, strlen(rfbScreen->desktopName)); -- cgit v1.2.3 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(-) (limited to 'libvncserver') 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.3 From 7cb0e4a9a95886300268e1bff1e72b4c18f1b762 Mon Sep 17 00:00:00 2001 From: Christian Beier Date: Wed, 9 Nov 2011 19:20:10 +0100 Subject: novnc client: use the client's notion about the server hostname instead of what the server thinks. --- classes/index.vnc | 15 ++++++++++++++- libvncserver/httpd.c | 4 ---- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'libvncserver') diff --git a/classes/index.vnc b/classes/index.vnc index 1a05d01..34ad25d 100644 --- a/classes/index.vnc +++ b/classes/index.vnc @@ -5,9 +5,11 @@ signs ($$) to get a dollar sign in the generated html. --> + $USER's $DESKTOP desktop ($DISPLAY) + @@ -15,8 +17,19 @@ $USER's $DESKTOP desktop ($DISPLAY)

+ If the above Java applet does not work, you can also try the new JavaScript-only noVNC viewer. You will need a HTML5-capable browser though. -Click here to connect using noVNC. + +
+ +
+


diff --git a/libvncserver/httpd.c b/libvncserver/httpd.c index 3252fc6..3025aae 100644 --- a/libvncserver/httpd.c +++ b/libvncserver/httpd.c @@ -431,10 +431,6 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen) sprintf(str, "%d", rfbScreen->port); rfbWriteExact(&cl, str, strlen(str)); - } else if (compareAndSkip(&ptr, "$HOST")) { - - rfbWriteExact(&cl, rfbScreen->thisHost, strlen(rfbScreen->thisHost)); - } else if (compareAndSkip(&ptr, "$DESKTOP")) { rfbWriteExact(&cl, rfbScreen->desktopName, strlen(rfbScreen->desktopName)); -- cgit v1.2.3