$17 GRAYBYTE WORDPRESS FILE MANAGER $75

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 104.21.43.35 | ADMIN IP 216.73.216.157
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : mail

/opt/cpanel/ea-ruby27/root/usr/local/share/gems/gems/rack-2.2.4/lib/rack/

HOME
Current File : /opt/cpanel/ea-ruby27/root/usr/local/share/gems/gems/rack-2.2.4/lib/rack//conditional_get.rb
# frozen_string_literal: true

module Rack

  # Middleware that enables conditional GET using If-None-Match and
  # If-Modified-Since. The application should set either or both of the
  # Last-Modified or Etag response headers according to RFC 2616. When
  # either of the conditions is met, the response body is set to be zero
  # length and the response status is set to 304 Not Modified.
  #
  # Applications that defer response body generation until the body's each
  # message is received will avoid response body generation completely when
  # a conditional GET matches.
  #
  # Adapted from Michael Klishin's Merb implementation:
  # https://github.com/wycats/merb/blob/master/merb-core/lib/merb-core/rack/middleware/conditional_get.rb
  class ConditionalGet
    def initialize(app)
      @app = app
    end

    # Return empty 304 response if the response has not been
    # modified since the last request.
    def call(env)
      case env[REQUEST_METHOD]
      when "GET", "HEAD"
        status, headers, body = @app.call(env)
        headers = Utils::HeaderHash[headers]
        if status == 200 && fresh?(env, headers)
          status = 304
          headers.delete(CONTENT_TYPE)
          headers.delete(CONTENT_LENGTH)
          original_body = body
          body = Rack::BodyProxy.new([]) do
            original_body.close if original_body.respond_to?(:close)
          end
        end
        [status, headers, body]
      else
        @app.call(env)
      end
    end

  private

    # Return whether the response has not been modified since the
    # last request.
    def fresh?(env, headers)
      # If-None-Match has priority over If-Modified-Since per RFC 7232
      if none_match = env['HTTP_IF_NONE_MATCH']
        etag_matches?(none_match, headers)
      elsif (modified_since = env['HTTP_IF_MODIFIED_SINCE']) && (modified_since = to_rfc2822(modified_since))
        modified_since?(modified_since, headers)
      end
    end

    # Whether the ETag response header matches the If-None-Match request header.
    # If so, the request has not been modified.
    def etag_matches?(none_match, headers)
      headers['ETag'] == none_match
    end

    # Whether the Last-Modified response header matches the If-Modified-Since
    # request header.  If so, the request has not been modified.
    def modified_since?(modified_since, headers)
      last_modified = to_rfc2822(headers['Last-Modified']) and
        modified_since >= last_modified
    end

    # Return a Time object for the given string (which should be in RFC2822
    # format), or nil if the string cannot be parsed.
    def to_rfc2822(since)
      # shortest possible valid date is the obsolete: 1 Nov 97 09:55 A
      # anything shorter is invalid, this avoids exceptions for common cases
      # most common being the empty string
      if since && since.length >= 16
        # NOTE: there is no trivial way to write this in a non exception way
        #   _rfc2822 returns a hash but is not that usable
        Time.rfc2822(since) rescue nil
      end
    end
  end
end


Current_dir [ NOT WRITEABLE ] Document_root [ NOT WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
1 Jan 1970 12.00 AM
root / root
0
auth
--
24 Jun 2025 2.25 PM
root / root
0755
core_ext
--
24 Jun 2025 2.25 PM
root / root
0755
handler
--
24 Jun 2025 2.25 PM
root / root
0755
multipart
--
24 Jun 2025 2.25 PM
root / root
0755
session
--
24 Jun 2025 2.25 PM
root / root
0755
body_proxy.rb
1.271 KB
24 Jun 2025 2.25 PM
root / root
0644
builder.rb
8.205 KB
24 Jun 2025 2.25 PM
root / root
0644
cascade.rb
2.222 KB
24 Jun 2025 2.25 PM
root / root
0644
chunked.rb
3.193 KB
24 Jun 2025 2.25 PM
root / root
0644
common_logger.rb
2.955 KB
24 Jun 2025 2.25 PM
root / root
0644
conditional_get.rb
2.991 KB
24 Jun 2025 2.25 PM
root / root
0644
config.rb
0.4 KB
24 Jun 2025 2.25 PM
root / root
0644
content_length.rb
0.897 KB
24 Jun 2025 2.25 PM
root / root
0644
content_type.rb
0.668 KB
24 Jun 2025 2.25 PM
root / root
0644
deflater.rb
5.146 KB
24 Jun 2025 2.25 PM
root / root
0644
directory.rb
5.898 KB
24 Jun 2025 2.25 PM
root / root
0644
etag.rb
2.137 KB
24 Jun 2025 2.25 PM
root / root
0644
events.rb
4.717 KB
24 Jun 2025 2.25 PM
root / root
0644
file.rb
0.086 KB
24 Jun 2025 2.25 PM
root / root
0644
files.rb
5.737 KB
24 Jun 2025 2.25 PM
root / root
0644
handler.rb
2.872 KB
24 Jun 2025 2.25 PM
root / root
0644
head.rb
0.508 KB
24 Jun 2025 2.25 PM
root / root
0644
lint.rb
30.924 KB
24 Jun 2025 2.25 PM
root / root
0644
lobster.rb
1.96 KB
24 Jun 2025 2.25 PM
root / root
0644
lock.rb
0.699 KB
24 Jun 2025 2.25 PM
root / root
0644
logger.rb
0.375 KB
24 Jun 2025 2.25 PM
root / root
0644
media_type.rb
1.398 KB
24 Jun 2025 2.25 PM
root / root
0644
method_override.rb
1.293 KB
24 Jun 2025 2.25 PM
root / root
0644
mime.rb
32.39 KB
24 Jun 2025 2.25 PM
root / root
0644
mock.rb
8.294 KB
24 Jun 2025 2.25 PM
root / root
0644
multipart.rb
2.564 KB
24 Jun 2025 2.25 PM
root / root
0644
null_logger.rb
0.957 KB
24 Jun 2025 2.25 PM
root / root
0644
query_parser.rb
6.847 KB
24 Jun 2025 2.25 PM
root / root
0644
recursive.rb
1.75 KB
24 Jun 2025 2.25 PM
root / root
0644
reloader.rb
3.118 KB
24 Jun 2025 2.25 PM
root / root
0644
request.rb
19.69 KB
24 Jun 2025 2.25 PM
root / root
0644
response.rb
8.779 KB
24 Jun 2025 2.25 PM
root / root
0644
rewindable_input.rb
2.849 KB
24 Jun 2025 2.25 PM
root / root
0644
runtime.rb
0.864 KB
24 Jun 2025 2.25 PM
root / root
0644
sendfile.rb
5.449 KB
24 Jun 2025 2.25 PM
root / root
0644
server.rb
13.295 KB
24 Jun 2025 2.25 PM
root / root
0644
show_exceptions.rb
13.297 KB
24 Jun 2025 2.25 PM
root / root
0644
show_status.rb
3.421 KB
24 Jun 2025 2.25 PM
root / root
0644
static.rb
6.071 KB
24 Jun 2025 2.25 PM
root / root
0644
tempfile_reaper.rb
0.646 KB
24 Jun 2025 2.25 PM
root / root
0644
urlmap.rb
2.771 KB
24 Jun 2025 2.25 PM
root / root
0644
utils.rb
17.907 KB
24 Jun 2025 2.25 PM
root / root
0644
version.rb
0.767 KB
24 Jun 2025 2.25 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF