THRIFT-1560 Add setCustomHeaders() method to python thrift lib
Patch: Dave Watson

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1325041 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/py/src/transport/THttpClient.py b/lib/py/src/transport/THttpClient.py
index ad94d11..293d930 100644
--- a/lib/py/src/transport/THttpClient.py
+++ b/lib/py/src/transport/THttpClient.py
@@ -63,6 +63,7 @@
     self.__wbuf = StringIO()
     self.__http = None
     self.__timeout = None
+    self.__custom_headers = None
 
   def open(self):
     if self.scheme == 'http':
@@ -86,6 +87,9 @@
     else:
       self.__timeout = ms / 1000.0
 
+  def setCustomHeaders(self, headers):
+    self.__custom_headers = headers
+
   def read(self, sz):
     return self.__http.file.read(sz)
 
@@ -117,6 +121,11 @@
     self.__http.putheader('Host', self.host)
     self.__http.putheader('Content-Type', 'application/x-thrift')
     self.__http.putheader('Content-Length', str(len(data)))
+
+    if self.__custom_headers:
+        for key, val in self.__custom_headers.iteritems():
+            self.__http.putheader(key, val)
+
     self.__http.endheaders()
 
     # Write payload