Repository: valyala/fasthttp
Pull request #828 (2020-06-05 13:43:16)

Try TravisCI Windows


Patch:
diff --git a/.travis.yml b/.travis.yml
index b696430..f21d1a1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,14 +9,13 @@ dist: bionic
 os:
   - linux
   - osx
+  - windows
 go:
   - tip
   - 1.14.x
   - 1.13.x
   - 1.12.x
   - 1.11.x
-  - 1.10.x
-  - 1.9.x
 
 script:
   - go test -v ./...
diff --git a/go.mod b/go.mod
index 500d5d6..37e529d 100644
--- a/go.mod
+++ b/go.mod
@@ -4,9 +4,9 @@ go 1.11
 
 require (
 	github.com/andybalholm/brotli v1.0.0
-	github.com/klauspost/compress v1.10.4
+	github.com/klauspost/compress v1.10.7
 	github.com/valyala/bytebufferpool v1.0.0
 	github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a
-	golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e
-	golang.org/x/sys v0.0.0-20200602100848-8d3cce7afc34
+	golang.org/x/net v0.0.0-20200602114024-627f9648deb9
+	golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980
 )
diff --git a/go.sum b/go.sum
index d85bf3f..1109460 100644
--- a/go.sum
+++ b/go.sum
@@ -2,13 +2,17 @@ github.com/andybalholm/brotli v1.0.0 h1:7UCwP93aiSfvWpapti8g88vVVGp2qqtGyePsSuDa
 github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
 github.com/klauspost/compress v1.10.4 h1:jFzIFaf586tquEB5EhzQG0HwGNSlgAJpG53G6Ss11wc=
 github.com/klauspost/compress v1.10.4/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
+github.com/klauspost/compress v1.10.7 h1:7rix8v8GpI3ZBb0nSozFRgbtXKv+hOe+qfEpZqybrAg=
+github.com/klauspost/compress v1.10.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
 github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
 github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
 github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a h1:0R4NLDRDZX6JcmhJgXi5E4b8Wg84ihbmUKp/GvSPEzc=
 github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
-golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k=
-golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
-golang.org/x/sys v0.0.0-20200602100848-8d3cce7afc34 h1:u6CI7A++8r4SItZHYe2cWeAEndN4p1p+3Oum/Ft2EzM=
-golang.org/x/sys v0.0.0-20200602100848-8d3cce7afc34/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/net v0.0.0-20200602114024-627f9648deb9 h1:pNX+40auqi2JqRfOP1akLGtYcn15TUbkhwuCO3foqqM=
+golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 h1:OjiUf46hAmXblsZdnoSXsEUSKU8r1UEzcL5RVZ4gO9Y=
+golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
diff --git a/prefork/prefork.go b/prefork/prefork.go
index 0b31ef5..cf1ff9f 100644
--- a/prefork/prefork.go
+++ b/prefork/prefork.go
@@ -1,3 +1,5 @@
+// +build !windows
+
 package prefork
 
 import (
@@ -22,7 +24,8 @@ var (
 	defaultLogger = Logger(log.New(os.Stderr, "", log.LstdFlags))
 	// ErrOverRecovery is returned when the times of starting over child prefork processes exceed
 	// the threshold.
-	ErrOverRecovery = errors.New("exceeding the value of RecoverThreshold")
+	ErrOverRecovery           = errors.New("exceeding the value of RecoverThreshold")
+	ErrOnlyReuseportOnWindows = errors.New("windows only supports Reuseport = true")
 )
 
 // Logger is used for logging formatted messages.
@@ -154,6 +157,10 @@ func (p *Prefork) doCommand() (*exec.Cmd, error) {
 
 func (p *Prefork) prefork(addr string) (err error) {
 	if !p.Reuseport {
+		if runtime.GOOS == "windows" {
+			return ErrOnlyReuseportOnWindows
+		}
+
 		if err = p.setTCPListenerFiles(addr); err != nil {
 			return
 		}
diff --git a/uri.go b/uri.go
index 0e6eb1b..695efe4 100644
--- a/uri.go
+++ b/uri.go
@@ -3,6 +3,7 @@ package fasthttp
 import (
 	"bytes"
 	"errors"
+	"fmt"
 	"io"
 	"sync"
 )
@@ -511,7 +512,7 @@ func (u *URI) updateBytes(newURI, buf []byte) []byte {
 		path := u.Path()
 		n = bytes.LastIndexByte(path, '/')
 		if n < 0 {
-			panic("BUG: path must contain at least one slash")
+			panic(fmt.Sprintf("BUG: path must contain at least one slash: %s %s", u.Path(), newURI))
 		}
 		buf = u.appendSchemeHost(buf[:0])
 		buf = appendQuotedPath(buf, path[:n+1])


Test patch:
diff --git a/fasthttputil/pipeconns_test.go b/fasthttputil/pipeconns_test.go
index 017dd57..97c294f 100644
--- a/fasthttputil/pipeconns_test.go
+++ b/fasthttputil/pipeconns_test.go
@@ -128,7 +128,7 @@ func TestPipeConnsCloseWhileReadWriteConcurrent(t *testing.T) {
 	for i := 0; i < concurrency; i++ {
 		select {
 		case <-ch:
-		case <-time.After(3 * time.Second):
+		case <-time.After(5 * time.Second):
 			t.Fatalf("timeout")
 		}
 	}
diff --git a/fs_test.go b/fs_test.go
index 07c74dc..6484b31 100644
--- a/fs_test.go
+++ b/fs_test.go
@@ -9,6 +9,7 @@ import (
 	"math/rand"
 	"os"
 	"path"
+	"runtime"
 	"sort"
 	"testing"
 	"time"
@@ -740,6 +741,10 @@ func TestServeFileContentType(t *testing.T) {
 }
 
 func TestServeFileDirectoryRedirect(t *testing.T) {
+	if runtime.GOOS == "windows" {
+		t.SkipNow()
+	}
+
 	t.Parallel()
 
 	var ctx RequestCtx
diff --git a/prefork/prefork_test.go b/prefork/prefork_test.go
index 12f8445..f80c77a 100644
--- a/prefork/prefork_test.go
+++ b/prefork/prefork_test.go
@@ -1,3 +1,5 @@
+// +build !windows
+
 package prefork
 
 import (
@@ -91,6 +93,10 @@ func Test_listen(t *testing.T) {
 }
 
 func Test_setTCPListenerFiles(t *testing.T) {
+	if runtime.GOOS == "windows" {
+		t.SkipNow()
+	}
+
 	p := &Prefork{}
 	addr := getAddr()
 
diff --git a/server_test.go b/server_test.go
index 9381cb4..fba7598 100644
--- a/server_test.go
+++ b/server_test.go
@@ -982,7 +982,7 @@ func TestServerTLSReadTimeout(t *testing.T) {
 
 	select {
 	case err = <-r:
-	case <-time.After(time.Millisecond * 200):
+	case <-time.After(time.Millisecond * 500):
 	}
 
 	if err == nil {