liveserver

simple live web server for local developments
git clone https://noulin.net/git/liveserver.git
Log | Files | Refs | README | LICENSE

commit 4ab518c3e673d5d04f770d7ba35811459695b430
parent 29b8575a7aeee5b1a6c1ffcd4808a0291413313a
Author: Remy Noulin <loader2x@gmail.com>
Date:   Mon, 13 Nov 2017 08:27:08 +0100

fix lower case bug

README.md    | 10 ++++++++--
liveserver.c |  6 +++++-
package.yml  |  2 +-
server.log   |  8 --------
4 files changed, 14 insertions(+), 12 deletions(-)

Diffstat:
MREADME.md | 10++++++++--
Mliveserver.c | 6+++++-
Mpackage.yml | 2+-
Dserver.log | 8--------
4 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/README.md b/README.md @@ -1,5 +1,5 @@ -# live-server -simple live web server for local developments +# liveserver +simple live web server with websocket handshake for local developments, the pages in current folder are reloaded in the browser on updates. ## Install @@ -16,3 +16,9 @@ liveserver # HELP liveserver -help ``` + +## Based on + +- [simple-webserver](https://github.com/labcoder/simple-webserver) +- [libwebsock2](https://github.com/JonnyWhatshisface/libwebsock2) +- inspired by nodejs [live-server](https://www.npmjs.com/package/live-server) diff --git a/liveserver.c b/liveserver.c @@ -310,13 +310,17 @@ void web(int fd, int hit) size_t endBodyAt = 0; createAllocateSmallArray(f); readFileG(f, &buffer[5]); + smallStringt *tmp; enumerateSmallArray(f, S, n) { castS(s, S); - if (hasG(lowerG(s), "</body>")) { + tmp = dupG(s); + if (hasG(lowerG(tmp), "</body>")) { endBodyAt = n; + terminateG(tmp); finishG(s); break; } + terminateG(tmp); finishG(s); } injectSG(f, endBodyAt, injected); diff --git a/package.yml b/package.yml @@ -1,6 +1,6 @@ --- name: liveserver - version: 0.0.2 + version: 0.0.3 description: "simple web server that reloads when file updates are detected" bin: ./liveserver.c repository: diff --git a/server.log b/server.log @@ -1,8 +0,0 @@ - INFO: http server starting:8080:21304 - INFO: request:GET / HTTP/1.1**Host: 127.0.0.1:8080**User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0**Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8**Accept-Language: en-US,en;q=0.5**Accept-Encoding: gzip, deflate**Connection: keep-alive**Upgrade-Insecure-Requests: 1**Cache-Control: max-age=0****:1 - INFO: SEND:a:1 - INFO: request:GET /scott.jpg HTTP/1.1**Host: 127.0.0.1:8080**User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0**Accept: */***Accept-Language: en-US,en;q=0.5**Accept-Encoding: gzip, deflate**Referer: http://127.0.0.1:8080/**Connection: keep-alive**Cache-Control: max-age=0****:2 - INFO: SEND:scott.jpg:2 - INFO: request:GET //ws HTTP/1.1**Host: 127.0.0.1:8080**User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0**Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8**Accept-Language: en-US,en;q=0.5**Accept-Encoding: gzip, deflate**Sec-WebSocket-Version: 13**Origin: http://127.0.0.1:8080**Sec-WebSocket-Extensions: permessage-deflate**Sec-WebSocket-Key: WXZtbQjAV6Mm+b4CAr4VeQ==**Connection: keep-alive, Upgrade**Pragma: no-cache**Cache-Control: no-cache**Upgrade: websocket****:3 - INFO: websocket:detected:3 - INFO: key:WXZtbQjAV6Mm+b4CAr4VeQ==:3