Example #1
0
 def copyfile(self, infile, outfile):
     if not 'Range' in self.headers:
         SimpleHTTPRequestHandler.copyfile(self, infile, outfile)
         return
     outfile = open(outfile, 'wb')
     start, end = self.range
     infile.seek(start)
     bufsize = 64 * 1024  ## 64KB
     while True:
         buf = infile.read(bufsize)
         if not buf:
             break
         outfile.write(buf)
Example #2
0
    def copyfile(self, source, outputfile):
        if not self.range:
            return SimpleHTTPRequestHandler.copyfile(self, source, outputfile)

        # SimpleHTTPRequestHandler uses shutil.copyfileobj, which doesn't let
        # you stop the copying before the end of the file.
        start, stop = self.range  # set in send_head()
        copy_byte_range(source, outputfile, start, stop)
    def copyfile(self, source, outputfile):
        if not self.range:
            return SimpleHTTPRequestHandler.copyfile(self, source, outputfile)

        # SimpleHTTPRequestHandler uses shutil.copyfileobj, which doesn't let
        # you stop the copying before the end of the file.
        start, stop = self.range  # set in send_head()
        copy_byte_range(source, outputfile, start, stop)
Example #4
0
    def copyfile(self, source, outputfile):
        if isinstance(source, io.BytesIO):
            return SimpleHTTPRequestHandler.copyfile(self, source, outputfile)

        block_size = 16 * 1024
        while True:
            buf = source.read(block_size)
            if not buf:
                break

            total = len(buf)
            pos = 0
            while pos < total:
                ret = outputfile.write(buf[pos:])
                if ret is None:
                    break

                pos += ret