Skip to content

Commit

Permalink
improve logging for uni sse and uni http stream - avoid unnecessary e…
Browse files Browse the repository at this point in the history
…rrors
  • Loading branch information
FZambia committed Oct 31, 2023
1 parent a910535 commit ccdd99a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/unihttpstream/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
r.Body = http.MaxBytesReader(w, r.Body, maxBytesSize)
connectRequestData, err := io.ReadAll(r.Body)
if err != nil {
h.node.Log(centrifuge.NewLogEntry(centrifuge.LogLevelInfo, "error reading uni http stream request body", map[string]any{"error": err.Error()}))
if len(connectRequestData) >= int(maxBytesSize) {
w.WriteHeader(http.StatusRequestEntityTooLarge)
return
}
h.node.Log(centrifuge.NewLogEntry(centrifuge.LogLevelError, "error reading body", map[string]any{"error": err.Error()}))
return
}
err = json.Unmarshal(connectRequestData, &req)
Expand Down
2 changes: 1 addition & 1 deletion internal/unisse/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
r.Body = http.MaxBytesReader(w, r.Body, int64(maxBytesSize))
connectRequestData, err := io.ReadAll(r.Body)
if err != nil {
h.node.Log(centrifuge.NewLogEntry(centrifuge.LogLevelInfo, "error reading uni sse request body", map[string]any{"error": err.Error()}))
if len(connectRequestData) >= maxBytesSize {
w.WriteHeader(http.StatusRequestEntityTooLarge)
return
}
h.node.Log(centrifuge.NewLogEntry(centrifuge.LogLevelError, "error reading body", map[string]any{"error": err.Error()}))
return
}
err = json.Unmarshal(connectRequestData, &req)
Expand Down

0 comments on commit ccdd99a

Please sign in to comment.