gotify / server

A simple server for sending and receiving messages in real-time per WebSocket. (Includes a sleek web-ui)
https://gotify.net
Other
11.52k stars 639 forks source link

head method in health endpoint #688

Closed moinologics closed 2 months ago

moinologics commented 2 months ago

Fixes #687

eternal-flame-AD commented 2 months ago

@moinologics I tested this with socat, seems like gin internally strips the body if the verb was HEAD, so this code produces a compliant behavior (except dynamically generated JSON should not have a content-length on HEAD). However I still think this is not ideal, we shouldn't rely on undocumented error-catching features and write code with a looks-wrong semantics.

Feel free to @ jmattheis for a second opinion :) Everybody has different styles and preferences

eternal-flame-AD commented 2 months ago

Here's a solution I think is robust, (maybe even a little overkill?) , but at the very least I think connection, content type and content-encoding must be the same, and content length must not be present.

https://github.com/gotify/server/commit/b43e7cdc8ccdea2c09042704c05f5c3561e96d1f

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 80.46%. Comparing base (a58b0be) to head (2e0210d). Report is 1 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #688 +/- ## ======================================= Coverage 80.46% 80.46% ======================================= Files 56 56 Lines 2191 2191 ======================================= Hits 1763 1763 Misses 337 337 Partials 91 91 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.