You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2011/04/10 19:43:49 UTC
svn commit: r1090850 - /incubator/libcloud/trunk/libcloud/common/base.py
Author: tomaz
Date: Sun Apr 10 17:43:49 2011
New Revision: 1090850
URL: http://svn.apache.org/viewvc?rev=1090850&view=rev
Log:
Add a pre connect hook which gets called before sending a request to the remote
server and can perform final manipulation with the requests parameters and
headers.
Modified:
incubator/libcloud/trunk/libcloud/common/base.py
Modified: incubator/libcloud/trunk/libcloud/common/base.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/common/base.py?rev=1090850&r1=1090849&r2=1090850&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/common/base.py (original)
+++ incubator/libcloud/trunk/libcloud/common/base.py Sun Apr 10 17:43:49 2011
@@ -345,6 +345,8 @@ class ConnectionKey(object):
if data is not None:
headers.update({'Content-Length': str(len(data))})
+ params, headers = self.pre_connect_hook(params, headers)
+
if params:
url = '?'.join((action, urllib.urlencode(params)))
else:
@@ -395,6 +397,20 @@ class ConnectionKey(object):
"""
return headers
+ def pre_connect_hook(self, params, headers):
+ """
+ A hook which is called before connecting to the remote server.
+ This hook can perform a final manipulation on the params, headers and
+ url parameters.
+
+ @type params: C{dict}
+ @param params: Request parameters.
+
+ @type headers: C{dict}
+ @param headers: Request headers.
+ """
+ return params, headers
+
def encode_data(self, data):
"""
Encode body data.