this seems to fix problem with upload. Tested with the django app

This commit is contained in:
benoitc 2010-02-28 22:22:09 +01:00
parent d50420848e
commit ea02c5e073
3 changed files with 9 additions and 3 deletions

View File

@ -26,6 +26,7 @@ def home(request):
tmp = tempfile.TemporaryFile()
for chunk in f.chunks():
tmp.write(chunk)
tmp.flush()
size = int(os.fstat(tmp.fileno())[6])
else:
form = MsgForm()

View File

@ -33,7 +33,7 @@ class TeeInput(object):
if len(buf) > 0:
chunk, self.buf = parser.filter_body(buf)
if chunk:
fwrite(self.tmp, chunk)
self.tmp.write(chunk)
self._finalize()
self.tmp.seek(0)
@ -42,9 +42,12 @@ class TeeInput(object):
if self._len: return self._len
if self._is_socket:
pos = self.tmp.tell()
while True:
self.tmp.seek(self._tmp_size())
if not self._tee(CHUNK_SIZE):
break
self.tmp.seek(0)
self._len = self._tmp_size()
return self._len
@ -133,7 +136,9 @@ class TeeInput(object):
chunk, self.buf = self.parser.filter_body(self.buf)
if chunk:
fwrite(self.tmp, chunk)
self.tmp.write(chunk)
self.tmp.flush()
self.tmp.seek(0, os.SEEK_END)
return chunk
if self.parser.body_eof():

View File

@ -194,7 +194,7 @@ def test_011(buf, p):
t.eq(body, "hello world")
@t.request("017.http")
def test_017(buf, p):
def test_013(buf, p):
headers = []
i = p.filter_headers(headers, buf)
t.ne(i, -1)