resp = []
respsent = []
- def write(data):
- if not data:
- return
+ def flushreq():
if not respsent:
if not resp:
raise Exception, "Trying to write data before starting response."
for nm, val in headers:
req.sk.write("%s: %s\n" % (nm, val))
req.sk.write("\n")
+
+ def write(data):
+ if not data:
+ return
+ flushreq()
req.sk.write(data)
req.sk.flush()
try:
for data in respiter:
write(data)
- write("")
+ if resp:
+ flushreq()
finally:
if hasattr(respiter, "close"):
respiter.close()
resp = []
respsent = []
- def write(data):
- if not data:
- return
+ def flushreq():
if not respsent:
if not resp:
raise Exception, "Trying to write data before starting response."
for nm, val in headers:
sk.write("%s: %s\n" % (nm, val))
sk.write("\n")
+
+ def write(data):
+ if not data:
+ return
+ flushreq()
sk.write(data)
sk.flush()
try:
for data in respiter:
write(data)
- write("")
+ if resp:
+ flushresp()
finally:
if hasattr(respiter, "close"):
respiter.close()