]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Using shutil's function to copy data between file objects instead
authorMoshe Zadka <moshez@math.huji.ac.il>
Sat, 29 Jul 2000 05:15:56 +0000 (05:15 +0000)
committerMoshe Zadka <moshez@math.huji.ac.il>
Sat, 29 Jul 2000 05:15:56 +0000 (05:15 +0000)
of rolling our own.

Note:
This is my first sourceforge checkin. If you see anything funny about
this patch, please let me know.

Lib/SimpleHTTPServer.py

index 71254131202b5423f75ccf135444610e73b8febf..8a7775856c96f3bac853d3e5a850ce69741b135e 100644 (file)
@@ -15,6 +15,7 @@ import posixpath
 import BaseHTTPServer
 import urllib
 import cgi
+import shutil
 from StringIO import StringIO
 
 
@@ -151,12 +152,7 @@ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
         to copy binary data as well.
 
         """
-
-        BLOCKSIZE = 8192
-        while 1:
-            data = source.read(BLOCKSIZE)
-            if not data: break
-            outputfile.write(data)
+        shutil.copyfileobj(source, outputfile)
 
     def guess_type(self, path):
         """Guess the type of a file.