~pythonregexp2.7/python/issue2636-12

« back to all changes in this revision

Viewing changes to Lib/SimpleHTTPServer.py

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-09-21 17:58:08 UTC
  • mfrom: (39033.1.6 Regexp-2.7)
  • Revision ID: darklord@timehorse.com-20080921175808-j16o8cmct0t3f2uk
Merged in changes from the core Regexp branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
            else:
80
80
                return self.list_directory(path)
81
81
        ctype = self.guess_type(path)
82
 
        if ctype.startswith('text/'):
83
 
            mode = 'r'
84
 
        else:
85
 
            mode = 'rb'
86
82
        try:
87
 
            f = open(path, mode)
 
83
            # Always read in binary mode. Opening files in text mode may cause
 
84
            # newline translations, making the actual size of the content
 
85
            # transmitted *less* than the content-length!
 
86
            f = open(path, 'rb')
88
87
        except IOError:
89
88
            self.send_error(404, "File not found")
90
89
            return None