Sha256: 8c1fdc21f4a6725c3187e142072f7ab10944f810436e8086462610763146427d

Contents?: true

Size: 744 Bytes

Versions: 32

Compression:

Stored size: 744 Bytes

Contents

# frozen-string-literal: true

#
class Roda
  module RodaPlugins
    # The status_303 plugin sets the default redirect status to be 303
    # rather than 302 when the request is not a GET and the
    # redirection occurs on an HTTP 1.1 connection as per RFC 7231.
    # There are some frontend frameworks that require this behavior.
    #
    # Example:
    #
    #   plugin :status_303
    module Status303
      module RequestMethods

        private

        def default_redirect_status
          return super if is_get?

          case http_version
          when 'HTTP/1.0', 'HTTP/0.9', nil
            super
          else
            303
          end
        end
      end
    end

    register_plugin(:status_303, Status303)
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
roda-3.88.0 lib/roda/plugins/status_303.rb
roda-3.87.0 lib/roda/plugins/status_303.rb
roda-3.86.0 lib/roda/plugins/status_303.rb
roda-3.85.0 lib/roda/plugins/status_303.rb
roda-3.84.0 lib/roda/plugins/status_303.rb
roda-3.83.0 lib/roda/plugins/status_303.rb
roda-3.82.0 lib/roda/plugins/status_303.rb
roda-3.81.0 lib/roda/plugins/status_303.rb
roda-3.79.0 lib/roda/plugins/status_303.rb
roda-3.78.0 lib/roda/plugins/status_303.rb
roda-3.77.0 lib/roda/plugins/status_303.rb
roda-3.76.0 lib/roda/plugins/status_303.rb
roda-3.75.0 lib/roda/plugins/status_303.rb
roda-3.74.0 lib/roda/plugins/status_303.rb
roda-3.73.0 lib/roda/plugins/status_303.rb
roda-3.72.0 lib/roda/plugins/status_303.rb
roda-3.71.0 lib/roda/plugins/status_303.rb
roda-3.70.0 lib/roda/plugins/status_303.rb
roda-3.69.0 lib/roda/plugins/status_303.rb
roda-3.68.0 lib/roda/plugins/status_303.rb