-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request
Description
If a previous WriteHeader(404) was invoked, line 231 gets executed provoking a second Write.
noda-tasks-management-tool-api/main.go
Lines 230 to 232 in c9e0c6a
| if http.StatusNotFound == recorder.statusCode() { | |
| failure.EmitError(w, failure.ErrTargetNotFound, true) | |
| } |
Check EmitError implementation:
noda-tasks-management-tool-api/failure/error.go
Lines 328 to 353 in c9e0c6a
| func EmitError(w http.ResponseWriter, e *Error, wroteHeader ...bool) { | |
| var response = &errorBody{ | |
| Code: e.code, | |
| Message: e.message, | |
| Hint: e.hint, | |
| } | |
| var buf = []byte(e.details) | |
| err := json.Unmarshal(buf, &response.Details) | |
| if nil != err { | |
| var s *json.SyntaxError | |
| if errors.As(err, &s) { | |
| /* A normal string is expected. */ | |
| response.Details = &e.details | |
| } | |
| } | |
| res, err := json.Marshal(response) | |
| if err != nil { | |
| log.Println(err) | |
| w.WriteHeader(http.StatusInternalServerError) | |
| return | |
| } | |
| if 0 == len(wroteHeader) || !wroteHeader[0] { | |
| w.WriteHeader(e.status) | |
| } | |
| w.Write(res) | |
| } |
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request
Projects
Status
No status