--- a/src/ztfy/utils/protocol/http.py Tue May 20 15:54:43 2014 +0200
+++ b/src/ztfy/utils/protocol/http.py Mon Sep 15 12:40:10 2014 +0200
@@ -17,6 +17,7 @@
# import standard packages
import httplib2
import urllib
+import urlparse
# import Zope3 interfaces
@@ -70,6 +71,15 @@
return response, content
-def getClient(method, protocol, servername, url, params={}, credentials=(), proxy=(), rdns=True, proxy_auth=(), timeout=None, headers={}):
+def getClient(method, protocol, servername, url, params={}, credentials=(), proxy=(),
+ rdns=True, proxy_auth=(), timeout=None, headers={}):
"""HTTP client factory"""
- return HTTPClient(method, protocol, servername, url, params, credentials, proxy, rdns, proxy_auth, timeout, headers)
+ return HTTPClient(method, protocol, servername, url, params, credentials, proxy,
+ rdns, proxy_auth, timeout, headers)
+
+
+def getClientFromURL(url, credentials=(), proxy=(), rdns=True, proxy_auth=(), timeout=None, headers={}):
+ """HTTP client factory from URL"""
+ elements = urlparse.urlparse(url)
+ return HTTPClient('GET', elements.scheme, elements.netloc, elements.path, elements.params,
+ credentials, proxy, rdns, proxy_auth, timeout, headers)