diff options
author | Mateusz Gajewski <[email protected]> | 2016-10-25 18:45:30 +0200 |
---|---|---|
committer | Mateusz Gajewski <[email protected]> | 2016-10-25 19:19:54 +0200 |
commit | 8cc3416bbcb0900d451bf95cbb1363870b39a7ea (patch) | |
tree | 1cbfb086caa245a5d808e43f2cabde0af94aec26 /caddyhttp | |
parent | c4d64a418ba122058cc08a6893c0c489960f91d9 (diff) | |
download | caddy-8cc3416bbcb0900d451bf95cbb1363870b39a7ea.tar.gz caddy-8cc3416bbcb0900d451bf95cbb1363870b39a7ea.zip |
Remove dead code, do struct alignment, simplify code
Diffstat (limited to 'caddyhttp')
-rw-r--r-- | caddyhttp/browse/browse.go | 2 | ||||
-rw-r--r-- | caddyhttp/fastcgi/fcgiclient.go | 24 | ||||
-rw-r--r-- | caddyhttp/fastcgi/fcgiclient_test.go | 2 | ||||
-rw-r--r-- | caddyhttp/markdown/markdown.go | 2 | ||||
-rw-r--r-- | caddyhttp/proxy/proxy.go | 12 | ||||
-rw-r--r-- | caddyhttp/proxy/upstream.go | 31 | ||||
-rw-r--r-- | caddyhttp/rewrite/rewrite.go | 5 |
7 files changed, 25 insertions, 53 deletions
diff --git a/caddyhttp/browse/browse.go b/caddyhttp/browse/browse.go index 63ad14aff..24ef8d76a 100644 --- a/caddyhttp/browse/browse.go +++ b/caddyhttp/browse/browse.go @@ -101,12 +101,12 @@ func (l Listing) BreadcrumbMap() map[string]string { // FileInfo is the info about a particular file or directory type FileInfo struct { - IsDir bool Name string Size int64 URL string ModTime time.Time Mode os.FileMode + IsDir bool } // HumanSize returns the size of the file as a human-readable string diff --git a/caddyhttp/fastcgi/fcgiclient.go b/caddyhttp/fastcgi/fcgiclient.go index d3773c9b4..4f0d28d10 100644 --- a/caddyhttp/fastcgi/fcgiclient.go +++ b/caddyhttp/fastcgi/fcgiclient.go @@ -44,7 +44,6 @@ const FCGINullRequestID uint8 = 0 // FCGIKeepConn describes keep connection mode. const FCGIKeepConn uint8 = 1 -const doubleCRLF = "\r\n\r\n" const ( // BeginRequest is the begin request flag. @@ -261,29 +260,6 @@ func (c *FCGIClient) writePairs(recType uint8, pairs map[string]string) error { return nil } -func readSize(s []byte) (uint32, int) { - if len(s) == 0 { - return 0, 0 - } - size, n := uint32(s[0]), 1 - if size&(1<<7) != 0 { - if len(s) < 4 { - return 0, 0 - } - n = 4 - size = binary.BigEndian.Uint32(s) - size &^= 1 << 31 - } - return size, n -} - -func readString(s []byte, size uint32) string { - if size > uint32(len(s)) { - return "" - } - return string(s[:size]) -} - func encodeSize(b []byte, size uint32) int { if size > 127 { size |= 1 << 31 diff --git a/caddyhttp/fastcgi/fcgiclient_test.go b/caddyhttp/fastcgi/fcgiclient_test.go index c4d997844..0048c25b0 100644 --- a/caddyhttp/fastcgi/fcgiclient_test.go +++ b/caddyhttp/fastcgi/fcgiclient_test.go @@ -155,7 +155,7 @@ func sendFcgi(reqType int, fcgiParams map[string]string, data []byte, posts map[ fcgi.Close() time.Sleep(1 * time.Second) - if bytes.Index(content, []byte("FAILED")) >= 0 { + if bytes.Contains(content, []byte("FAILED")) { globalt.Error("Server return failed message") } diff --git a/caddyhttp/markdown/markdown.go b/caddyhttp/markdown/markdown.go index 94b5b61ef..933e5af74 100644 --- a/caddyhttp/markdown/markdown.go +++ b/caddyhttp/markdown/markdown.go @@ -144,7 +144,7 @@ func (md Markdown) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error } w.Header().Set("Content-Type", "text/html; charset=utf-8") - w.Header().Set("Content-Length", strconv.FormatInt(int64(len(html)), 10)) + w.Header().Set("Content-Length", strconv.Itoa(len(html))) httpserver.SetLastModifiedHeader(w, lastModTime) if r.Method == http.MethodGet { w.Write(html) diff --git a/caddyhttp/proxy/proxy.go b/caddyhttp/proxy/proxy.go index a46ea71a6..bee689285 100644 --- a/caddyhttp/proxy/proxy.go +++ b/caddyhttp/proxy/proxy.go @@ -46,17 +46,17 @@ type UpstreamHostDownFunc func(*UpstreamHost) bool // UpstreamHost represents a single proxy upstream type UpstreamHost struct { - Conns int64 // must be first field to be 64-bit aligned on 32-bit systems + Conns int64 // must be first field to be 64-bit aligned on 32-bit systems + MaxConns int64 Name string // hostname of this upstream host - ReverseProxy *ReverseProxy - Fails int32 - FailTimeout time.Duration - Unhealthy bool UpstreamHeaders http.Header DownstreamHeaders http.Header + FailTimeout time.Duration CheckDown UpstreamHostDownFunc WithoutPathPrefix string - MaxConns int64 + ReverseProxy *ReverseProxy + Fails int32 + Unhealthy bool } // Down checks whether the upstream host is down or not. diff --git a/caddyhttp/proxy/upstream.go b/caddyhttp/proxy/upstream.go index c5ca77f07..dba4af3c8 100644 --- a/caddyhttp/proxy/upstream.go +++ b/caddyhttp/proxy/upstream.go @@ -21,27 +21,26 @@ var ( ) type staticUpstream struct { - from string - upstreamHeaders http.Header - downstreamHeaders http.Header - Hosts HostPool - Policy Policy - KeepAlive int - insecureSkipVerify bool - - FailTimeout time.Duration - MaxFails int32 - TryDuration time.Duration - TryInterval time.Duration - MaxConns int64 - HealthCheck struct { + from string + upstreamHeaders http.Header + downstreamHeaders http.Header + Hosts HostPool + Policy Policy + KeepAlive int + FailTimeout time.Duration + TryDuration time.Duration + TryInterval time.Duration + MaxConns int64 + HealthCheck struct { Client http.Client Path string Interval time.Duration Timeout time.Duration } - WithoutPathPrefix string - IgnoredSubPaths []string + WithoutPathPrefix string + IgnoredSubPaths []string + insecureSkipVerify bool + MaxFails int32 } // NewStaticUpstreams parses the configuration input and sets up diff --git a/caddyhttp/rewrite/rewrite.go b/caddyhttp/rewrite/rewrite.go index da086e438..13fb8df53 100644 --- a/caddyhttp/rewrite/rewrite.go +++ b/caddyhttp/rewrite/rewrite.go @@ -216,10 +216,7 @@ func (r *ComplexRule) matchExt(rPath string) bool { } } - if mustUse { - return false - } - return true + return !mustUse } func (r *ComplexRule) regexpMatches(rPath string) []string { |