From e96b602cb88e78adfed009ccd620c4385af01a0b Mon Sep 17 00:00:00 2001 From: Stormwind Date: Thu, 1 Jun 2023 09:11:34 +0200 Subject: Correct HTTP status code on redirect With the release of RFC 7231 in June 2014 the HTTP status code 302 - Moved Temporarily does no longer exist in this form and has been replaced by 302 - Found, which causes the browser to use the same request method to call the new resource. Which can cause unwanted deletions of resouces, when a child resource is deleted and the browser gets redirected to the parent resource. Instead we use now the status code 303 - See Others, which specifies, that the referred resource has to be called using the GET method. --- lib/zero/response.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/zero/response.rb b/lib/zero/response.rb index 272e5e2..63441e9 100644 --- a/lib/zero/response.rb +++ b/lib/zero/response.rb @@ -85,10 +85,11 @@ module Zero self.header['Content-Type'] = value end - # Sets the Location header to the given URL and the status code to 302. + # Sets the Location header to the given URL and the status code to + # 303 - See Other. # # @param [String] location Redirect URL - def redirect(location, status = 302) + def redirect(location, status = 303) self.status = status self.header['Location'] = location end -- cgit v1.2.3-70-g09d2