kit icon indicating copy to clipboard operation
kit copied to clipboard

http.EncodeJSONResponse body writing is not compatible with net/http

Open kerma opened this issue 1 month ago • 2 comments

What did you do?

  1. Implemented http.StatusCoder() which returns 304 (Not Modified)
  2. 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.

kerma avatar May 10 '24 17:05 kerma