kit
kit copied to clipboard
http.EncodeJSONResponse body writing is not compatible with net/http
What did you do?
- Implemented http.StatusCoder() which returns 304 (Not Modified)
- Observed an error when http.EncodeJSONResponse is called:
http: request method or response status code does not allow body
It seems that body is not written only on 204: https://github.com/go-kit/kit/blob/master/transport/http/server.go#L177
However, stdlib defines "no body allowed" as 100-199, 204, 304: https://cs.opensource.google/go/go/+/refs/tags/go1.22.3:src/net/http/transfer.go;l=460
What did you expect?
No error.
What happened instead?
Got an error.