mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
use mimetools; add close()
This commit is contained in:
parent
e7808778d6
commit
65ab98c427
1 changed files with 8 additions and 2 deletions
|
@ -33,7 +33,7 @@ import socket
|
||||||
import string
|
import string
|
||||||
import regex
|
import regex
|
||||||
import regsub
|
import regsub
|
||||||
import rfc822
|
import mimetools
|
||||||
|
|
||||||
HTTP_VERSION = 'HTTP/1.0'
|
HTTP_VERSION = 'HTTP/1.0'
|
||||||
HTTP_PORT = 80
|
HTTP_PORT = 80
|
||||||
|
@ -46,6 +46,7 @@ class HTTP:
|
||||||
|
|
||||||
def __init__(self, host = '', port = 0):
|
def __init__(self, host = '', port = 0):
|
||||||
self.debuglevel = 0
|
self.debuglevel = 0
|
||||||
|
self.file = None
|
||||||
if host: self.connect(host, port)
|
if host: self.connect(host, port)
|
||||||
|
|
||||||
def set_debuglevel(self, debuglevel):
|
def set_debuglevel(self, debuglevel):
|
||||||
|
@ -90,12 +91,17 @@ class HTTP:
|
||||||
errcode, errmsg = replyprog.group(1, 2)
|
errcode, errmsg = replyprog.group(1, 2)
|
||||||
errcode = string.atoi(errcode)
|
errcode = string.atoi(errcode)
|
||||||
errmsg = string.strip(errmsg)
|
errmsg = string.strip(errmsg)
|
||||||
self.headers = rfc822.Message(self.file, 0)
|
self.headers = mimetools.Message(self.file, 0)
|
||||||
return errcode, errmsg, self.headers
|
return errcode, errmsg, self.headers
|
||||||
|
|
||||||
def getfile(self):
|
def getfile(self):
|
||||||
return self.file
|
return self.file
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
if self.file:
|
||||||
|
self.file.close()
|
||||||
|
self.file = None
|
||||||
|
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
import sys
|
import sys
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue