diff --git a/gluon/rocket.py b/gluon/rocket.py index 373c46b3..eb7c5c57 100644 --- a/gluon/rocket.py +++ b/gluon/rocket.py @@ -1850,12 +1850,13 @@ class WSGIWorker(Worker): if data: self.write(data, sections) + if not self.headers_sent: + # Send headers if the body was empty + self.send_headers('', sections) + if self.chunked: # If chunked, send our final chunk length self.conn.sendall(b('0\r\n\r\n')) - elif not self.headers_sent: - # Send headers if the body was empty - self.send_headers('', sections) # Don't capture exceptions here. The Worker class handles # them appropriately.