$87 GRAYBYTE WORDPRESS FILE MANAGER $65

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

/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//rewindable_input.rb
# -*- encoding: binary -*-
# frozen_string_literal: true

require 'tempfile'

module Rack
  # Class which can make any IO object rewindable, including non-rewindable ones. It does
  # this by buffering the data into a tempfile, which is rewindable.
  #
  # rack.input is required to be rewindable, so if your input stream IO is non-rewindable
  # by nature (e.g. a pipe or a socket) then you can wrap it in an object of this class
  # to easily make it rewindable.
  #
  # Don't forget to call #close when you're done. This frees up temporary resources that
  # RewindableInput uses, though it does *not* close the original IO object.
  class RewindableInput
    def initialize(io)
      @io = io
      @rewindable_io = nil
      @unlinked = false
    end

    def gets
      make_rewindable unless @rewindable_io
      @rewindable_io.gets
    end

    def read(*args)
      make_rewindable unless @rewindable_io
      @rewindable_io.read(*args)
    end

    def each(&block)
      make_rewindable unless @rewindable_io
      @rewindable_io.each(&block)
    end

    def rewind
      make_rewindable unless @rewindable_io
      @rewindable_io.rewind
    end

    # Closes this RewindableInput object without closing the originally
    # wrapped IO object. Cleans up any temporary resources that this RewindableInput
    # has created.
    #
    # This method may be called multiple times. It does nothing on subsequent calls.
    def close
      if @rewindable_io
        if @unlinked
          @rewindable_io.close
        else
          @rewindable_io.close!
        end
        @rewindable_io = nil
      end
    end

    private

    def make_rewindable
      # Buffer all data into a tempfile. Since this tempfile is private to this
      # RewindableInput object, we chmod it so that nobody else can read or write
      # it. On POSIX filesystems we also unlink the file so that it doesn't
      # even have a file entry on the filesystem anymore, though we can still
      # access it because we have the file handle open.
      @rewindable_io = Tempfile.new('RackRewindableInput')
      @rewindable_io.chmod(0000)
      @rewindable_io.set_encoding(Encoding::BINARY) if @rewindable_io.respond_to?(:set_encoding)
      @rewindable_io.binmode
      if filesystem_has_posix_semantics?
        raise 'Unlink failed. IO closed.' if @rewindable_io.closed?
        @unlinked = true
      end

      buffer = "".dup
      while @io.read(1024 * 4, buffer)
        entire_buffer_written_out = false
        while !entire_buffer_written_out
          written = @rewindable_io.write(buffer)
          entire_buffer_written_out = written == buffer.bytesize
          if !entire_buffer_written_out
            buffer.slice!(0 .. written - 1)
          end
        end
      end
      @rewindable_io.rewind
    end

    def filesystem_has_posix_semantics?
      RUBY_PLATFORM !~ /(mswin|mingw|cygwin|java)/
    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