Skip to content

Commit e552856

Browse files
committed
'修复了content-length错误的问题'
1 parent e8b4aa2 commit e552856

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

httpserver.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ def send_head(self):
159159
headers = dict(self.headers)
160160
fs = os.stat(path)
161161

162+
self.send_header("Content-Length", str(fs[6]))
163+
self.send_header("Last-Modified", self.date_time_string(fs.st_mtime))
164+
self.send_header("Accept-Ranges", "bytes")
165+
162166
if 'if-modified-since' in headers:
163167
ims = headers['if-modified-since']
164168
ims = parse_date(ims.split(";")[0].strip())
@@ -188,9 +192,6 @@ def send_head(self):
188192
self.send_header("Content-type", mimetype)
189193
#if encoding:
190194
# self.send_header("Content-Encoding", encoding)
191-
self.send_header("Content-Length", str(fs[6]))
192-
self.send_header("Last-Modified", self.date_time_string(fs.st_mtime))
193-
self.send_header("Accept-Ranges", "bytes")
194195
self.end_headers()
195196
result = StringIO()
196197
result.write(f)

0 commit comments

Comments
 (0)