perwendel / spark

A simple expressive web framework for java. Spark has a kotlin DSL https://github.com/perwendel/spark-kotlin
Apache License 2.0
9.63k stars 1.56k forks source link

Response body not possible (null) if HTTP status code is 304 (not modified). #1267

Open fsilkswan opened 1 year ago

fsilkswan commented 1 year ago

Hi there,

I've come to notice that it is not possible to deliver a response body to an arbitrary client in case the HTTP status code is set to 304 in the Response object. Client's will not receive any content, even the Route returns a String and/or the body field of the Response is set.

The other 3xx codes seem to allow a response body though.

Is there a reason why 304 has a special treatment regarding the response body?

Kind regards -Ferdinand-

qrhfz commented 1 year ago

MDN says "The response must not contain a body " it's the http standard https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/304

fsilkswan commented 11 months ago

I see, thanks for your time!