| # Copyright (c) 2006- Facebook |
| # Distributed under the Thrift Software License |
| # See accompanying file LICENSE or visit the Thrift site at: |
| # http://developers.facebook.com/thrift/ |
| from cStringIO import StringIO |
| class THttpClient(TTransportBase): |
| """Http implementation of TTransport base.""" |
| def __init__(self, host, port, uri): |
| self.__http = httplib.HTTP(self.host, self.port) |
| return self.__http != None |
| return self.__http.file.read(sz) |
| # Pull data out of buffer |
| data = self.__wbuf.getvalue() |
| self.__http.putrequest('POST', self.uri) |
| self.__http.putheader('Host', self.host) |
| self.__http.putheader('Content-Type', 'application/x-thrift') |
| self.__http.putheader('Content-Length', str(len(data))) |
| # Get reply to flush the request |
| self.code, self.message, self.headers = self.__http.getreply() |