From 8559750f7ad012b517dd308ffb08a3bfbe759f0c Mon Sep 17 00:00:00 2001 From: TomTriple Date: Sun, 24 Sep 2023 21:57:51 +0200 Subject: [PATCH] add note regarding classical "redirect after post" situations (#2434) --- zio-http/src/main/scala/zio/http/Response.scala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/zio-http/src/main/scala/zio/http/Response.scala b/zio-http/src/main/scala/zio/http/Response.scala index b01d42cff5..75c33ed68b 100644 --- a/zio-http/src/main/scala/zio/http/Response.scala +++ b/zio-http/src/main/scala/zio/http/Response.scala @@ -263,8 +263,11 @@ object Response { def ok: Response = status(Status.Ok) /** - * Creates an empty response with status 301 or 302 depending on if it's + * Creates an empty response with status 307 or 308 depending on if it's * permanent or not. + * + * Note: if you intend to always redirect a browser with a HTTP GET to the + * given location you very likely should use `Response#seeOther` instead. */ def redirect(location: URL, isPermanent: Boolean = false): Response = { val status = if (isPermanent) Status.PermanentRedirect else Status.TemporaryRedirect @@ -272,7 +275,7 @@ object Response { } /** - * Creates an empty response with status 303 + * Creates an empty response with status 303. */ def seeOther(location: URL): Response = Response(status = Status.SeeOther, headers = Headers(Header.Location(location)))