[Python-checkins] CVS: python/dist/src/Lib httplib.py,1.25,1.26
Guido van Rossum
python-dev@python.org
Fri, 15 Dec 2000 07:09:46 -0800
Update of /cvsroot/python/python/dist/src/Lib
In directory slayer.i.sourceforge.net:/tmp/cvs-serv18082
Modified Files:
httplib.py
Log Message:
Get rid of string functions.
There should really be a little tool to help with this -- it's rather
tedious and there are lots of special cases!
Index: httplib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -r1.25 -r1.26
*** httplib.py 2000/12/11 20:32:20 1.25
--- httplib.py 2000/12/15 15:09:42 1.26
***************
*** 68,72 ****
import socket
- import string
import mimetools
--- 68,71 ----
***************
*** 113,120 ****
print "reply:", repr(line)
try:
! [version, status, reason] = string.split(line, None, 2)
except ValueError:
try:
! [version, status] = string.split(line, None, 1)
reason = ""
except ValueError:
--- 112,119 ----
print "reply:", repr(line)
try:
! [version, status, reason] = line.split(None, 2)
except ValueError:
try:
! [version, status] = line.split(None, 1)
reason = ""
except ValueError:
***************
*** 127,131 ****
self.status = status = int(status)
! self.reason = string.strip(reason)
if version == 'HTTP/1.0':
--- 126,130 ----
self.status = status = int(status)
! self.reason = reason.strip()
if version == 'HTTP/1.0':
***************
*** 153,157 ****
tr_enc = self.msg.getheader('transfer-encoding')
if tr_enc:
! if string.lower(tr_enc) != 'chunked':
raise UnknownTransferEncoding()
self.chunked = 1
--- 152,156 ----
tr_enc = self.msg.getheader('transfer-encoding')
if tr_enc:
! if tr_enc.lower() != 'chunked':
raise UnknownTransferEncoding()
self.chunked = 1
***************
*** 163,171 ****
conn = self.msg.getheader('connection')
if conn:
! conn = string.lower(conn)
# a "Connection: close" will always close the connection. if we
# don't see that and this is not HTTP/1.1, then the connection will
# close unless we see a Keep-Alive header.
! self.will_close = string.find(conn, 'close') != -1 or \
( self.version != 11 and \
not self.msg.getheader('keep-alive') )
--- 162,170 ----
conn = self.msg.getheader('connection')
if conn:
! conn = conn.lower()
# a "Connection: close" will always close the connection. if we
# don't see that and this is not HTTP/1.1, then the connection will
# close unless we see a Keep-Alive header.
! self.will_close = conn.find('close') != -1 or \
( self.version != 11 and \
not self.msg.getheader('keep-alive') )
***************
*** 225,232 ****
if chunk_left is None:
line = self.fp.readline()
! i = string.find(line, ';')
if i >= 0:
line = line[:i] # strip chunk-extensions
! chunk_left = string.atoi(line, 16)
if chunk_left == 0:
break
--- 224,231 ----
if chunk_left is None:
line = self.fp.readline()
! i = line.find(';')
if i >= 0:
line = line[:i] # strip chunk-extensions
! chunk_left = int(line, 16)
if chunk_left == 0:
break
***************
*** 332,336 ****
def _set_hostport(self, host, port):
if port is None:
! i = string.find(host, ':')
if i >= 0:
port = int(host[i+1:])
--- 331,335 ----
def _set_hostport(self, host, port):
if port is None:
! i = host.find(':')
if i >= 0:
port = int(host[i+1:])
***************
*** 672,677 ****
def putheader(self, header, *values):
"The superclass allows only one value argument."
! self._conn.putheader(header,
! string.joinfields(values, '\r\n\t'))
def getreply(self):
--- 671,675 ----
def putheader(self, header, *values):
"The superclass allows only one value argument."
! self._conn.putheader(header, '\r\n\t'.join(values))
def getreply(self):
***************
*** 799,803 ****
print
if headers:
! for header in headers.headers: print string.strip(header)
print
print h.getfile().read()
--- 797,801 ----
print
if headers:
! for header in headers.headers: print header.strip()
print
print h.getfile().read()
***************
*** 814,818 ****
print
if headers:
! for header in headers.headers: print string.strip(header)
print
print hs.getfile().read()
--- 812,816 ----
print
if headers:
! for header in headers.headers: print header.strip()
print
print hs.getfile().read()