Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 37c03ff

Browse files
author
Moshe Zadka
committed
Using shutil's function to copy data between file objects instead
of rolling our own. Note: This is my first sourceforge checkin. If you see anything funny about this patch, please let me know.
1 parent 10853c9 commit 37c03ff

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

Lib/SimpleHTTPServer.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import BaseHTTPServer
1616
import urllib
1717
import cgi
18+
import shutil
1819
from StringIO import StringIO
1920

2021

@@ -151,12 +152,7 @@ def copyfile(self, source, outputfile):
151152
to copy binary data as well.
152153
153154
"""
154-
155-
BLOCKSIZE = 8192
156-
while 1:
157-
data = source.read(BLOCKSIZE)
158-
if not data: break
159-
outputfile.write(data)
155+
shutil.copyfileobj(source, outputfile)
160156

161157
def guess_type(self, path):
162158
"""Guess the type of a file.

0 commit comments

Comments
 (0)