summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorKjetil Jacobsen <kjetilja@gmail.com>2005-05-09 08:44:42 +0000
committerKjetil Jacobsen <kjetilja@gmail.com>2005-05-09 08:44:42 +0000
commit03966ada223e65300cf422a190a3b2b199a387da (patch)
treece5a43dd180014f251e47ce8199a93259f0df87e /python
parent8d03ffce868573038873d2872a51ab3d3161593c (diff)
downloadpycurl-03966ada223e65300cf422a190a3b2b199a387da.tar.gz
- added a get_info method and cleaned up some of the code
Diffstat (limited to 'python')
-rw-r--r--python/curl/__init__.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/python/curl/__init__.py b/python/curl/__init__.py
index 8fecb4d..d32c7e0 100644
--- a/python/curl/__init__.py
+++ b/python/curl/__init__.py
@@ -17,7 +17,7 @@ except ImportError:
class Curl:
- "High-level interface to cURL functions."
+ "High-level interface to pycurl functions."
def __init__(self, base_url="", fakeheaders=[]):
self.handle = pycurl.Curl()
# These members might be set.
@@ -58,7 +58,7 @@ class Curl:
self.set_option(pycurl.URL, self.base_url)
def set_option(self, *args):
- "Set an option on the retrieval,"
+ "Set an option on the retrieval."
apply(self.handle.setopt, args)
def set_verbosity(self, level):
@@ -93,6 +93,10 @@ class Curl:
"Return the body from the last response."
return self.payload
+ def get_info(self, *args):
+ "Get information about retrieval."
+ return apply(self.handle.getinfo, args)
+
def info(self):
"Return an RFC822 object with info on the page."
self.header.seek(0,0)
@@ -126,8 +130,11 @@ class Curl:
def close(self):
"Close a session, freeing resources."
- self.handle.close()
- self.header.close()
+ if self.handle: self.handle.close()
+ if self.header: self.header.close()
+ self.handle = None
+ self.header = None
+ self.payload = ""
def __del__(self):
self.close()