Skip to content

Commit dd1c9d6

Browse files
committed
agent: check ps length
1 parent cd8f92b commit dd1c9d6

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

agent/http.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ func parsePortsParam(w http.ResponseWriter, req *http.Request) ([]uint32, error)
3232
log.Debugf("Looking for process(es) for ports: %s\n", portsParam)
3333

3434
if portsParam == "" {
35-
log.Errorln("ports param is not provided.")
36-
return nil, fmt.Errorf("ports param is required") //todo: check again.
35+
return nil, fmt.Errorf("ports param is required")
3736
}
3837

3938
ports := strings.Split(portsParam, ",")
@@ -109,11 +108,11 @@ func (a *Agent) Process(w http.ResponseWriter, req *http.Request) {
109108
// todo: cache result for a short period (10s? 30s?)
110109
ports, err := parsePortsParam(w, req)
111110
if err != nil {
112-
http.Error(w, "port param is required", http.StatusBadRequest)
111+
http.Error(w, "port params is required", http.StatusBadRequest)
113112
return
114113
}
115114
ps := findProcesses(ports, a.GetConns())
116-
if ps == nil {
115+
if len(ps) == 0 {
117116
http.Error(w, "Connection(s) not found", http.StatusNotFound)
118117
return
119118
}

0 commit comments

Comments
 (0)