# File lib_doc/rucy/local.rb, line 326
    def publish_range(file, stat, req_path, request, response)
      if (request.header('Range') =~ /^bytes=(\d+)-(\d+)?$/) then
        first_pos = $1.to_i
        if ($2) then
          last_pos = $2.to_i
          if (last_pos > stat.size - 1) then
            last_pos = stat.size - 1
          end
        else
          last_pos = stat.size - 1
        end
        if (first_pos <= last_pos) then
          partial_size = last_pos - first_pos + 1
          response.status = 206 # Partial Content
          response.set_header('Content-Type', @type_resolver.content_type(req_path))
          response.set_header('Content-Range', "bytes #{first_pos}-#{last_pos}/#{stat.size}")
          response.set_header('Content-Length', partial_size.to_s)
          response.set_header('Last-Modified', stat.mtime.httpdate)
          response.start_body
          if (request.method != 'HEAD') then
            file.seek(first_pos)
            while (partial_size > @chunk_size)
              data = file.read(@chunk_size) or break
              response.write(data)
              partial_size -= data.length
            end
            while (partial_size > 0)
              data = file.read(partial_size) or break
              response.write(data)
              partial_size -= data.length
            end
          end
          return true
        else
          response.status = 416 # Requested Range Not Satisfiable
          response.start_body
          return true
        end
      end

      false
    end