Skip to content

Commit 2a3df99

Browse files
authored
Merge pull request #373 from LK4D4/fix_staticcheck
Fix some simple issues found by staticcheck
2 parents 0df2c85 + 9032271 commit 2a3df99

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

libwebsocketd/env.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ func createEnv(handler *WebsocketdHandler, req *http.Request, log *LogScope) []s
4242
env = appendEnv(env, "SERVER_SOFTWARE", handler.server.Config.ServerSoftware)
4343

4444
parentStarts := len(env)
45-
for _, v := range handler.server.Config.ParentEnv {
46-
env = append(env, v)
47-
}
45+
env = append(env, handler.server.Config.ParentEnv...)
4846

4947
// IMPORTANT ---> Adding a header? Make sure standardEnvCount (above) is up to date.
5048

libwebsocketd/http.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (h *WebsocketdServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
7171

7272
if h.Config.CommandName != "" || h.Config.UsingScriptDir {
7373
hdrs := req.Header
74-
upgradeRe := regexp.MustCompile("(?i)(^|[,\\s])Upgrade($|[,\\s])")
74+
upgradeRe := regexp.MustCompile(`(?i)(^|[,\s])Upgrade($|[,\s])`)
7575
// WebSocket, limited to size of h.forks
7676
if strings.ToLower(hdrs.Get("Upgrade")) == "websocket" && upgradeRe.MatchString(hdrs.Get("Connection")) {
7777
if h.noteForkCreated() == nil {
@@ -118,7 +118,7 @@ func (h *WebsocketdServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
118118

119119
} else {
120120
log.Error("http", "Max of possible forks already active, upgrade rejected")
121-
http.Error(w, "429 Too Many Requests", 429)
121+
http.Error(w, "429 Too Many Requests", http.StatusTooManyRequests)
122122
}
123123
return
124124
}
@@ -162,7 +162,7 @@ func (h *WebsocketdServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
162162
cgiHandler.ServeHTTP(w, req)
163163
} else {
164164
log.Error("http", "Fork not allowed since maxforks amount has been reached. CGI was not run.")
165-
http.Error(w, "429 Too Many Requests", 429)
165+
http.Error(w, "429 Too Many Requests", http.StatusTooManyRequests)
166166
}
167167
return
168168
}
@@ -228,7 +228,6 @@ func (h *WebsocketdServer) noteForkCompled() {
228228
panic("Cannot deplet number of allowed forks, something is not right in code!")
229229
}
230230
}
231-
return
232231
}
233232

234233
func checkOrigin(req *http.Request, config *Config, log *LogScope) (err error) {

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ func main() {
109109
}(addrSingle)
110110
}
111111
}
112-
select {
113-
case err := <-rejects:
112+
err := <-rejects
113+
if err != nil {
114114
log.Fatal("server", "Can't start server: %s", err)
115115
os.Exit(3)
116116
}

0 commit comments

Comments
 (0)