metosin / ring-http-response

Handling HTTP Statuses with Clojure(Script)
Eclipse Public License 1.0
149 stars 24 forks source link

Inconsistent :body defaults in ring.util.http-response #19

Closed Elknar closed 6 years ago

Elknar commented 7 years ago

Some responses default to a nil body, while others use an empty string.

For example, compare ok and no-content.

leblowl commented 6 years ago

I was thinking the same thing, it doesn't look like nil vs empty string has any obvious effect on the response, I get content-length: 0 for both. I suggest we just pick one.

Ring uses empty strings here: https://github.com/ring-clojure/ring/blob/736394806167cb2af87716655f73da9f8fbd0226/ring-core/src/ring/util/response.clj#L20-L36

And nil here: https://github.com/ring-clojure/ring/blob/736394806167cb2af87716655f73da9f8fbd0226/ring-core/src/ring/util/response.clj#L38-L45

Deraen commented 6 years ago

Empty string is used for responses which will never have a body, i.e. non-entity response types like informational (100-199) or redirection (300-399). This is to match to the linked Ring redirect and redirect-after-post functions.

leblowl commented 6 years ago

Awesome, thanks for the info

On Tue, Mar 20, 2018, 08:53 Juho Teperi notifications@github.com wrote:

Empty string is used for responses which will never have a body, i.e. non-entity response types like informational (100-199) or redirection (300-399). This is to match to the linked Ring redirect and redirect-after-post functions.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/metosin/ring-http-response/issues/19#issuecomment-374627161, or mute the thread https://github.com/notifications/unsubscribe-auth/AD2siGKLEi6_iKNQAWBHk7CESkVOPFrVks5tgRffgaJpZM4QGcU6 .