@@ -323,7 +323,7 @@ class HTTPResponse:
323323 # accepts iso-8859-1.
324324
325325 def __init__ (self , sock , debuglevel = 0 , strict = 0 , method = None ):
326- self .fp = sock .makefile ('rb' , 0 )
326+ self .fp = sock .makefile ("rb" , 0 )
327327 self .debuglevel = debuglevel
328328 self .strict = strict
329329 self ._method = method
@@ -359,7 +359,7 @@ def _read_status(self):
359359 # empty version will cause next test to fail and status
360360 # will be treated as 0.9 response.
361361 version = ""
362- if not version .startswith (' HTTP/' ):
362+ if not version .startswith (" HTTP/" ):
363363 if self .strict :
364364 self .close ()
365365 raise BadStatusLine (line )
@@ -397,11 +397,11 @@ def begin(self):
397397
398398 self .status = status
399399 self .reason = reason .strip ()
400- if version == ' HTTP/1.0' :
400+ if version == " HTTP/1.0" :
401401 self .version = 10
402- elif version .startswith (' HTTP/1.' ):
402+ elif version .startswith (" HTTP/1." ):
403403 self .version = 11 # use HTTP/1.1 code for HTTP/1.x where x>=1
404- elif version == ' HTTP/0.9' :
404+ elif version == " HTTP/0.9" :
405405 self .version = 9
406406 else :
407407 raise UnknownProtocol (version )
@@ -416,13 +416,13 @@ def begin(self):
416416 self .msg = HTTPMessage (self .fp , 0 )
417417 if self .debuglevel > 0 :
418418 for hdr in self .msg .headers :
419- print ("header:" , hdr , end = ' ' )
419+ print ("header:" , hdr , end = " " )
420420
421421 # don't let the msg keep an fp
422422 self .msg .fp = None
423423
424424 # are we using the chunked-style of transfer encoding?
425- tr_enc = self .msg .getheader (' transfer-encoding' )
425+ tr_enc = self .msg .getheader (" transfer-encoding" )
426426 if tr_enc and tr_enc .lower () == "chunked" :
427427 self .chunked = 1
428428 self .chunk_left = None
@@ -434,7 +434,7 @@ def begin(self):
434434
435435 # do we have a Content-Length?
436436 # NOTE: RFC 2616, S4.4, #3 says we ignore this if tr_enc is "chunked"
437- length = self .msg .getheader (' content-length' )
437+ length = self .msg .getheader (" content-length" )
438438 if length and not self .chunked :
439439 try :
440440 self .length = int (length )
@@ -446,7 +446,7 @@ def begin(self):
446446 # does the body have a fixed length? (of zero)
447447 if (status == NO_CONTENT or status == NOT_MODIFIED or
448448 100 <= status < 200 or # 1xx codes
449- self ._method == ' HEAD' ):
449+ self ._method == " HEAD" ):
450450 self .length = 0
451451
452452 # if the connection remains open, and we aren't using chunked, and
@@ -458,11 +458,11 @@ def begin(self):
458458 self .will_close = 1
459459
460460 def _check_close (self ):
461- conn = self .msg .getheader (' connection' )
461+ conn = self .msg .getheader (" connection" )
462462 if self .version == 11 :
463463 # An HTTP/1.1 proxy is assumed to stay open unless
464464 # explicitly closed.
465- conn = self .msg .getheader (' connection' )
465+ conn = self .msg .getheader (" connection" )
466466 if conn and "close" in conn .lower ():
467467 return True
468468 return False
@@ -471,7 +471,7 @@ def _check_close(self):
471471 # connections, using rules different than HTTP/1.1.
472472
473473 # For older HTTP, Keep-Alive indiciates persistent connection.
474- if self .msg .getheader (' keep-alive' ):
474+ if self .msg .getheader (" keep-alive" ):
475475 return False
476476
477477 # At least Akamai returns a "Connection: Keep-Alive" header,
@@ -480,7 +480,7 @@ def _check_close(self):
480480 return False
481481
482482 # Proxy-Connection is a netscape hack.
483- pconn = self .msg .getheader (' proxy-connection' )
483+ pconn = self .msg .getheader (" proxy-connection" )
484484 if pconn and "keep-alive" in pconn .lower ():
485485 return False
486486
@@ -505,7 +505,7 @@ def isclosed(self):
505505
506506 def read (self , amt = None ):
507507 if self .fp is None :
508- return ''
508+ return ""
509509
510510 if self .chunked :
511511 return self ._read_chunked (amt )
@@ -537,14 +537,14 @@ def read(self, amt=None):
537537 def _read_chunked (self , amt ):
538538 assert self .chunked != _UNKNOWN
539539 chunk_left = self .chunk_left
540- value = ''
540+ value = ""
541541
542542 # XXX This accumulates chunks by repeated string concatenation,
543543 # which is not efficient as the number or size of chunks gets big.
544544 while True :
545545 if chunk_left is None :
546546 line = self .fp .readline ()
547- i = line .find (';' )
547+ i = line .find (";" )
548548 if i >= 0 :
549549 line = line [:i ] # strip chunk-extensions
550550 chunk_left = int (line , 16 )
@@ -573,7 +573,7 @@ def _read_chunked(self, amt):
573573 ### note: we shouldn't have any trailers!
574574 while True :
575575 line = self .fp .readline ()
576- if line == ' \r \n ' :
576+ if line == " \r \n " :
577577 break
578578
579579 # we read everything; close the "file"
@@ -602,7 +602,7 @@ def _safe_read(self, amt):
602602 raise IncompleteRead (s )
603603 s .append (chunk )
604604 amt -= len (chunk )
605- return '' .join (s )
605+ return "" .join (s )
606606
607607 def getheader (self , name , default = None ):
608608 if self .msg is None :
0 commit comments