Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 1587

Show
Ignore:
Timestamp:
01/05/07 10:58:52
Author:
fumanchu
Message:

Optimized [1586], and fixed a bug where we didn't meet the WSGI spec regarding sending headers only after the first NON-EMPTY data.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/wsgiserver.py

    r1586 r1587  
    364364        try: 
    365365            for chunk in response: 
    366                 self.write(chunk) 
     366                # "The start_response callable must not actually transmit 
     367                # the response headers. Instead, it must store them for the 
     368                # server or gateway to transmit only after the first 
     369                # iteration of the application return value that yields 
     370                # a NON-EMPTY string, or upon the application's first 
     371                # invocation of the write() callable." (PEP 333) 
     372                if chunk: 
     373                    self.write(chunk) 
    367374        finally: 
    368375            if hasattr(response, "close"): 
     
    415422            self.sent_headers = True 
    416423            self.send_headers() 
    417         if self.chunked_write and len(chunk): 
    418             buf = [hex(len(chunk))[2:], 
    419                   "\r\n", chunk, "\r\n"] 
     424         
     425        if self.chunked_write and chunk: 
     426            buf = [hex(len(chunk))[2:], "\r\n", chunk, "\r\n"] 
    420427            self.sendall("".join(buf)) 
    421428        else: 

Hosted by WebFaction

Log in as guest/cpguest to create tickets