module Sinatra::Helpers

def redirect(uri, *args)

Halt processing and redirect to the URI provided.
def redirect(uri, *args)
  # SERVER_PROTOCOL is required in Rack 3, fall back to HTTP_VERSION
  # for servers not updated for Rack 3 (like Puma 5)
  http_version = env['SERVER_PROTOCOL'] || env['HTTP_VERSION']
  if (http_version == 'HTTP/1.1') && (env['REQUEST_METHOD'] != 'GET')
    status 303
  else
    status 302
  end
  # According to RFC 2616 section 14.30, "the field value consists of a
  # single absolute URI"
  response['Location'] = uri(uri.to_s, settings.absolute_redirects?, settings.prefixed_redirects?)
  halt(*args)
end