<div>Philipp,</div>
<div>Sorry for being lazy, and thanks for the tips. Here is my update version.</div>
<div>--- httptask.py.orig Fri Jan 06 02:15:48 2006<br>+++ httptask.py Fri Sep 22 09:13:48 2006<br>@@ -126,6 +126,11 @@<br> else:<br> close_it = 1<br> elif version == '1.1':<br>+ #modified by Simon
<br>+ if 'connection: close' in (header.lower() for header in<br>+ self.accumulated_headers):<br>+ #Close if 'connection: close' found in http response's header
<br>+ close_it = 1<br> if connection == 'close':<br> close_it = 1<br> elif 'Transfer-Encoding' in response_headers:<br>@@ -134,8 +139,13 @@<br> elif self.status
== '304':<br> # Replying with headers only.<br> pass<br>+ #modified by simon<br> elif not ('Content-Length' in response_headers):<br>- close_it = 1<br>
+ if 'content-length' not in (header[:14].lower() for header in<br>+ self.accumulated_headers):<br>+ #Close if 'content-length' not found in<br>
+ #http response's header and self.response_headers<br>+ close_it = 1<br> else:<br> # Close if unrecognized HTTP version.<br> close_it = 1<br><br> </div>
<div><span class="gmail_quote">On 9/21/06, <b class="gmail_sendername">Philipp von Weitershausen</b> <<a href="mailto:philipp@weitershausen.de">philipp@weitershausen.de</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hi Simon,<br><br>I have a few comments regarding style. First::<br><br> if thisflag == False:<br> ...
<br><br>is unnecessarily long. Just write::<br><br> if not thisflag:<br> ...<br><br>Also, what is "thisflag"? It'd be better to give it a descriptive name.<br><br>> --- httptask.py.orig Fri Jan 06 02:15:48 2006
<br>> +++ httptask.py Thu Sep 21 17:31:17 2006<br>> @@ -126,6 +126,15 @@<br>> else:<br>> close_it = 1<br>> elif version == '1.1':<br>> + #modified by Simon
<br>> + thisflag = False<br>> + for each in self.accumulated_headers:<br>> + if each.lower() == 'connection: keep-alive':<br>> + thisflag = True<br>> + break
<br>> + if thisflag == False:<br>> + close_it = 1<br>> +<br><br>I think you make this a lot simpler::<br><br> if 'connection: keep-alive' not in (header.lower() for header in<br>
self.accumulated_headers):<br> close_it = 1<br><br>(instead of the lines you added)<br><br>> if connection == 'close':<br>> close_it = 1<br>> elif 'Transfer-Encoding' in response_headers:
<br>> @@ -134,8 +143,15 @@<br>> elif self.status == '304':<br>> # Replying with headers only.<br>> pass<br>> + #modified by simon<br>> elif not ('Content-Length' in response_headers):
<br>> - close_it = 1<br>> + thisflag = False<br>> + for each in self.accumulated_headers:<br>> + if each[:14].lower() == 'content-length':<br>> + thisflag = True
<br>> + break<br>> + if thisflag == False: #only content_length not exist in<br>> accumulated headers too<br>> + close_it = 1<br><br>I don't understand the comment (English grammar not correct), but my
<br>suggestion would apply here as well, I think.<br></blockquote></div><br>