Skip to content

Commit

Permalink
discard endrequest(); minor stuff; rfc822 no seek flag
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanrossum committed Jun 22, 1995
1 parent 2d95706 commit 4cdcef7
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Lib/httplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# >>> h.putreqest('GET', '/index.html')
# >>> h.putheader('Accept', 'text/html')
# >>> h.putheader('Accept', 'text/plain')
# >>> h.endheaders()
# >>> errcode, errmsg, headers = h.getreply()
# >>> if errcode == 200:
# ... f = h.getfile()
Expand Down Expand Up @@ -67,6 +68,7 @@ def send(self, str):
self.sock.send(str)

def putrequest(self, request, selector):
if not selector: selector = '/'
str = '%s %s %s\r\n' % (request, selector, HTTP_VERSION)
self.send(str)

Expand All @@ -77,13 +79,9 @@ def putheader(self, header, *args):
def endheaders(self):
self.send('\r\n')

def endrequest(self):
if self.debuglevel > 0: print 'shutdown: 1'
self.sock.shutdown(1)

def getreply(self):
self.endrequest()
self.file = self.sock.makefile('r')
self.sock = None
line = self.file.readline()
if self.debuglevel > 0: print 'reply:', `line`
if replyprog.match(line) < 0:
Expand All @@ -92,7 +90,7 @@ def getreply(self):
errcode, errmsg = replyprog.group(1, 2)
errcode = string.atoi(errcode)
errmsg = string.strip(errmsg)
self.headers = rfc822.Message(self.file)
self.headers = rfc822.Message(self.file, 0)
return errcode, errmsg, self.headers

def getfile(self):
Expand Down

0 comments on commit 4cdcef7

Please sign in to comment.