Software: Apache. PHP/5.6.40 uname -a: Linux cpanel06wh.bkk1.cloud.z.com 2.6.32-954.3.5.lve1.4.80.el6.x86_64 #1 SMP Thu Sep 24 uid=851(cp949260) gid=853(cp949260) groups=853(cp949260) Safe-mode: OFF (not secure) /opt/alt/ruby19/lib64/ruby/gems/1.9.1/doc/rack-1.6.4/rdoc/Rack/ drwxr-xr-x |
Viewing file: Select action/file-type: In FilesFilesClass/Module Index
Rack::FileRack::File serves files below the root directory given, according to the path info of the Rack request. e.g. when Rack::File.new("/etc") is used, you can access 'passwd' file as localhost:9292/passwd Handlers can detect if bodies are a Rack::File, and use mechanisms like sendfile on the path. ConstantsPublic Class MethodsPublic Instance Methods
_call(env)
click to toggle source
# File lib/rack/file.rb, line 36 def _call(env) unless ALLOWED_VERBS.include? env[REQUEST_METHOD] return fail(405, "Method Not Allowed", {'Allow' => ALLOW_HEADER}) end path_info = Utils.unescape(env[PATH_INFO]) clean_path_info = Utils.clean_path_info(path_info) @path = F.join(@root, clean_path_info) available = begin F.file?(@path) && F.readable?(@path) rescue SystemCallError false end if available serving(env) else fail(404, "File not found: #{path_info}") end end
each()
click to toggle source
# File lib/rack/file.rb, line 101 def each F.open(@path, "rb") do |file| file.seek(@range.begin) remaining_len = @range.end-@range.begin+1 while remaining_len > 0 part = file.read([8192, remaining_len].min) break unless part remaining_len -= part.length yield part end end end
serving(env)
click to toggle source
# File lib/rack/file.rb, line 59 def serving(env) if env["REQUEST_METHOD"] == "OPTIONS" return [200, {'Allow' => ALLOW_HEADER, CONTENT_LENGTH => '0'}, []] end last_modified = F.mtime(@path).httpdate return [304, {}, []] if env['HTTP_IF_MODIFIED_SINCE'] == last_modified headers = { "Last-Modified" => last_modified } headers[CONTENT_TYPE] = mime_type if mime_type # Set custom headers @headers.each { |field, content| headers[field] = content } if @headers response = [ 200, headers, env[REQUEST_METHOD] == "HEAD" ? [] : self ] size = filesize ranges = Rack::Utils.byte_ranges(env, size) if ranges.nil? || ranges.length > 1 # No ranges, or multiple ranges (which we don't support): # TODO: Support multiple byte-ranges response[0] = 200 @range = 0..size-1 elsif ranges.empty? # Unsatisfiable. Return error, and file size: response = fail(416, "Byte range unsatisfiable") response[1]["Content-Range"] = "bytes */#{size}" return response else # Partial content: @range = ranges[0] response[0] = 206 response[1]["Content-Range"] = "bytes #{@range.begin}-#{@range.end}/#{size}" size = @range.end - @range.begin + 1 end response[2] = [response_body] unless response_body.nil? response[1][CONTENT_LENGTH] = size.to_s response end Generated with the Darkfish Rdoc Generator 2. |
:: Command execute :: | |
--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.02 ]-- |