$48 GRAYBYTE WORDPRESS FILE MANAGER $58

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.23
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/alt/ruby32/share/gems/gems/rack-3.0.8/lib/rack/

HOME
Current File : /opt/alt/ruby32/share/gems/gems/rack-3.0.8/lib/rack//etag.rb
# frozen_string_literal: true

require 'digest/sha2'

require_relative 'constants'
require_relative 'utils'

module Rack
  # Automatically sets the etag header on all String bodies.
  #
  # The etag header is skipped if etag or last-modified headers are sent or if
  # a sendfile body (body.responds_to :to_path) is given (since such cases
  # should be handled by apache/nginx).
  #
  # On initialization, you can pass two parameters: a cache-control directive
  # used when etag is absent and a directive when it is present. The first
  # defaults to nil, while the second defaults to "max-age=0, private, must-revalidate"
  class ETag
    ETAG_STRING = Rack::ETAG
    DEFAULT_CACHE_CONTROL = "max-age=0, private, must-revalidate"

    def initialize(app, no_cache_control = nil, cache_control = DEFAULT_CACHE_CONTROL)
      @app = app
      @cache_control = cache_control
      @no_cache_control = no_cache_control
    end

    def call(env)
      status, headers, body = response = @app.call(env)

      if etag_status?(status) && body.respond_to?(:to_ary) && !skip_caching?(headers)
        body = body.to_ary
        digest = digest_body(body)
        headers[ETAG_STRING] = %(W/"#{digest}") if digest
      end

      unless headers[CACHE_CONTROL]
        if digest
          headers[CACHE_CONTROL] = @cache_control if @cache_control
        else
          headers[CACHE_CONTROL] = @no_cache_control if @no_cache_control
        end
      end

      response
    end

    private

      def etag_status?(status)
        status == 200 || status == 201
      end

      def skip_caching?(headers)
        headers.key?(ETAG_STRING) || headers.key?('last-modified')
      end

      def digest_body(body)
        digest = nil

        body.each do |part|
          (digest ||= Digest::SHA256.new) << part unless part.empty?
        end

        digest && digest.hexdigest.byteslice(0,32)
      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
--
21 Mar 2024 12.54 PM
root / root
0755
multipart
--
21 Mar 2024 12.54 PM
root / root
0755
body_proxy.rb
1.3 KB
12 Feb 2024 9.33 PM
root / root
0644
builder.rb
8.562 KB
12 Feb 2024 9.33 PM
root / root
0644
cascade.rb
2.251 KB
12 Feb 2024 9.33 PM
root / root
0644
chunked.rb
3.301 KB
12 Feb 2024 9.33 PM
root / root
0644
common_logger.rb
3.117 KB
12 Feb 2024 9.33 PM
root / root
0644
conditional_get.rb
2.989 KB
12 Feb 2024 9.33 PM
root / root
0644
config.rb
0.4 KB
12 Feb 2024 9.33 PM
root / root
0644
constants.rb
2.474 KB
12 Feb 2024 9.33 PM
root / root
0644
content_length.rb
0.787 KB
12 Feb 2024 9.33 PM
root / root
0644
content_type.rb
0.679 KB
12 Feb 2024 9.33 PM
root / root
0644
deflater.rb
5.506 KB
12 Feb 2024 9.33 PM
root / root
0644
directory.rb
6.023 KB
12 Feb 2024 9.33 PM
root / root
0644
etag.rb
1.866 KB
12 Feb 2024 9.33 PM
root / root
0644
events.rb
4.801 KB
12 Feb 2024 9.33 PM
root / root
0644
file.rb
0.163 KB
12 Feb 2024 9.33 PM
root / root
0644
files.rb
5.661 KB
12 Feb 2024 9.33 PM
root / root
0644
head.rb
0.512 KB
12 Feb 2024 9.33 PM
root / root
0644
headers.rb
2.957 KB
12 Feb 2024 9.33 PM
root / root
0644
lint.rb
36.089 KB
12 Feb 2024 9.33 PM
root / root
0755
lock.rb
0.56 KB
12 Feb 2024 9.33 PM
root / root
0644
logger.rb
0.404 KB
12 Feb 2024 9.33 PM
root / root
0644
media_type.rb
1.399 KB
12 Feb 2024 9.33 PM
root / root
0644
method_override.rb
1.445 KB
12 Feb 2024 9.33 PM
root / root
0644
mime.rb
32.688 KB
12 Feb 2024 9.33 PM
root / root
0644
mock.rb
0.062 KB
12 Feb 2024 9.33 PM
root / root
0644
mock_request.rb
5.37 KB
12 Feb 2024 9.33 PM
root / root
0644
mock_response.rb
3.276 KB
12 Feb 2024 9.33 PM
root / root
0644
multipart.rb
1.166 KB
12 Feb 2024 9.33 PM
root / root
0644
null_logger.rb
1.185 KB
12 Feb 2024 9.33 PM
root / root
0644
query_parser.rb
8.37 KB
12 Feb 2024 9.33 PM
root / root
0644
recursive.rb
1.779 KB
12 Feb 2024 9.33 PM
root / root
0644
reloader.rb
3.022 KB
12 Feb 2024 9.33 PM
root / root
0644
request.rb
24.569 KB
12 Feb 2024 9.33 PM
root / root
0644
response.rb
10.724 KB
12 Feb 2024 9.33 PM
root / root
0644
rewindable_input.rb
3.123 KB
12 Feb 2024 9.33 PM
root / root
0644
runtime.rb
0.85 KB
12 Feb 2024 9.33 PM
root / root
0644
sendfile.rb
5.555 KB
12 Feb 2024 9.33 PM
root / root
0644
show_exceptions.rb
13.734 KB
12 Feb 2024 9.33 PM
root / root
0644
show_status.rb
3.576 KB
12 Feb 2024 9.33 PM
root / root
0644
static.rb
5.999 KB
12 Feb 2024 9.33 PM
root / root
0644
tempfile_reaper.rb
0.76 KB
12 Feb 2024 9.33 PM
root / root
0644
urlmap.rb
2.81 KB
12 Feb 2024 9.33 PM
root / root
0644
utils.rb
21.097 KB
12 Feb 2024 9.33 PM
root / root
0644
version.rb
0.936 KB
12 Feb 2024 9.33 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF