From 9f7a6a7232de1926dd96c05788f80ad42a243ad2 Mon Sep 17 00:00:00 2001 From: Alex Sergeyev Date: Thu, 2 Nov 2017 21:52:52 -0400 Subject: [PATCH] Starting some reworking with promising changes and fixing tests --- CHANGES | 5 +++++ README.md | 2 +- libwebsocketd/endpoint_test.go | 20 ++++++++++---------- libwebsocketd/http_test.go | 4 ++-- release/Makefile | 4 ++-- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/CHANGES b/CHANGES index 3e410c72..758041d3 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +Version 0.3.0 (??, 2017) + +* Migration of underlying websocket server to Gorilla Websocket lib. +* Binaries build code switched to 1.9.2 + Version 0.2.12 (Feb 17, 2016) * Update of underlying go standard libraries change how SSL works. SSL3 is no longer supported. diff --git a/README.md b/README.md index 4f96af7e..7a3d652f 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ from disk using a `file://` URL. More Features ------------- -* Very simple install. Just [download](https://github.com/joewalnes/websocketd/wiki/Download-and-install) the single executable for Linux, Mac or Windows and run it. No dependencies, no installers, no package managers, no external libraries. Suitable for development and production servers. +* Very simple install. Just [download](https://github.com/joewalnes/websocketd/wiki/Download-and-install) the single executable for Linux, Mac or Windows and run it. Minimal dependencies, no installers, no package managers, no external libraries. Suitable for development and production servers. * Server side scripts can access details about the WebSocket HTTP request (e.g. remote host, query parameters, cookies, path, etc) via standard [CGI environment variables](https://github.com/joewalnes/websocketd/wiki/Environment-variables). * As well as serving websocket daemons it also includes a static file server and classic CGI server for convenience. * Command line help available via `websocketd --help`. diff --git a/libwebsocketd/endpoint_test.go b/libwebsocketd/endpoint_test.go index 142f2953..a7a5dd52 100644 --- a/libwebsocketd/endpoint_test.go +++ b/libwebsocketd/endpoint_test.go @@ -19,8 +19,8 @@ var eol_answers = []string{ func TestTrimEOL(t *testing.T) { for n := 0; n < len(eol_tests); n++ { - answ := trimEOL(eol_tests[n]) - if answ != eol_answers[n] { + answ := trimEOL([]byte(eol_tests[n])) + if string(answ) != eol_answers[n] { t.Errorf("Answer '%s' did not match predicted '%s'", answ, eol_answers[n]) } } @@ -28,21 +28,21 @@ func TestTrimEOL(t *testing.T) { func BenchmarkTrimEOL(b *testing.B) { for n := 0; n < b.N; n++ { - trimEOL(eol_tests[n%len(eol_tests)]) + trimEOL([]byte(eol_tests[n%len(eol_tests)])) } } type TestEndpoint struct { limit int prefix string - c chan string + c chan []byte result []string } func (e *TestEndpoint) StartReading() { go func() { for i := 0; i < e.limit; i++ { - e.c <- e.prefix + strconv.Itoa(i) + e.c <- []byte(e.prefix + strconv.Itoa(i)) } time.Sleep(time.Millisecond) // should be enough for smaller channel to catch up with long one close(e.c) @@ -52,18 +52,18 @@ func (e *TestEndpoint) StartReading() { func (e *TestEndpoint) Terminate() { } -func (e *TestEndpoint) Output() chan string { +func (e *TestEndpoint) Output() chan []byte { return e.c } -func (e *TestEndpoint) Send(msg string) bool { - e.result = append(e.result, msg) +func (e *TestEndpoint) Send(msg []byte) bool { + e.result = append(e.result, string(msg)) return true } func TestEndpointPipe(t *testing.T) { - one := &TestEndpoint{2, "one:", make(chan string), make([]string, 0)} - two := &TestEndpoint{4, "two:", make(chan string), make([]string, 0)} + one := &TestEndpoint{2, "one:", make(chan []byte), make([]string, 0)} + two := &TestEndpoint{4, "two:", make(chan []byte), make([]string, 0)} PipeEndpoints(one, two) if len(one.result) != 4 || len(two.result) != 2 { t.Errorf("Invalid lengths, should be 4 and 2: %v %v", one.result, two.result) diff --git a/libwebsocketd/http_test.go b/libwebsocketd/http_test.go index 5296fe8b..18700deb 100644 --- a/libwebsocketd/http_test.go +++ b/libwebsocketd/http_test.go @@ -120,8 +120,8 @@ Sec-WebSocket-Version: 13 } var mimetest = [][3]string{ - {"Content-type: text/plain", "Content-type", "text/plain"}, - {"Content-type: ", "Content-type", ""}, + {"Content-Type: text/plain", "Content-Type", "text/plain"}, + {"Content-Type: ", "Content-Type", ""}, } func TestSplitMimeHeader(t *testing.T) { diff --git a/release/Makefile b/release/Makefile index fdfaa662..1a339649 100644 --- a/release/Makefile +++ b/release/Makefile @@ -5,7 +5,7 @@ # Uses Semantic Versioning scheme - http://semver.org/ VERSION_MAJOR=0 -VERSION_MINOR=2 +VERSION_MINOR=3 # Last part of version number (patch) is incremented automatically from Git tags LAST_PATCH_VERSION:=$(shell git ls-remote git@github.com:joewalnes/websocketd.git \ @@ -19,7 +19,7 @@ LAST_PATCH_VERSION:=$(shell git ls-remote git@github.com:joewalnes/websocketd.gi VERSION_PATCH:=$(if $(LAST_PATCH_VERSION),$(shell expr $(LAST_PATCH_VERSION)),0) RELEASE_VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH) -GO_VERSION=1.6.2 +GO_VERSION=1.9.2 PLATFORMS=linux_amd64 linux_386 linux_arm linux_arm64 darwin_amd64 freebsd_amd64 freebsd_386 windows_386 windows_amd64 openbsd_386 openbsd_amd64 solaris_amd64