def __init__(self, conn, container, name, content_type=None, reuse_token=True): self.raw_conn = None if reuse_token: self.url = conn.url token = conn.token else: self.url, token = conn.get_auth() self.parsed, self.conn = http_connection(self.url) self.path = '%s/%s/%s' % ( self.parsed.path.rstrip('/'), quote(smart_str(container)), quote(smart_str(name)), ) self.headers = { 'X-Auth-Token': token, 'Content-Type': content_type or 'application/octet-stream', 'Transfer-Encoding': 'chunked', 'Connection': 'close', # User-Agent ? } if conn.real_ip: self.headers['X-Forwarded-For'] = conn.real_ip logging.debug("ChunkedObject: path=%r, headers=%r" % (self.path, self.headers)) self.already_sent = 0
def __init__(self, conn, container, name, content_type=None, reuse_token = True): self.raw_conn = None if reuse_token: self.url = conn.url token = conn.token else: self.url, token = conn.get_auth() self.parsed, self.conn = http_connection(self.url) self.path = '%s/%s/%s' % (self.parsed.path.rstrip('/'), quote(smart_str(container)), quote(smart_str(name)), ) self.headers = { 'X-Auth-Token': token, 'Content-Type': content_type or 'application/octet-stream', 'Transfer-Encoding': 'chunked', 'Connection': 'close', # User-Agent ? } if conn.real_ip: self.headers['X-Forwarded-For'] = conn.real_ip logging.debug("ChunkedObject: path=%r, headers=%r" % (self.path, self.headers)) self.already_sent = 0
def __init__(self, conn, container, name, content_type=None): parsed, self.conn = http_connection(conn.url) logging.debug("ChunkObject: new connection open (%r, %r)" % (parsed, self.conn)) path = '%s/%s/%s' % (parsed.path.rstrip('/'), quote(smart_str(container)), quote(smart_str(name)), ) headers = { 'X-Auth-Token': conn.token, 'Content-Type': content_type or 'application/octet-stream', 'Transfer-Encoding': 'chunked', 'Connection': 'close', # User-Agent ? } if conn.real_ip: headers['X-Forwarded-For'] = conn.real_ip # we can't use the generator interface offered by requests to do a # chunked transfer encoded PUT, so we do this is to get control over the # "real" http connection and do the HTTP request ourselves self.raw_conn = self.conn.request_session.get_adapter(conn.url).get_connection(conn.url)._get_conn() self.raw_conn.putrequest('PUT', path, skip_accept_encoding=True) for key, value in headers.iteritems(): self.raw_conn.putheader(key, value) self.raw_conn.endheaders() logging.debug("ChunkedObject: path=%r, headers=%r" % (path, headers)) self.already_sent = 0
def __init__(self, conn, container, name, content_type=None): # FIXME # self._name_check() parsed, self.chunkable_http = http_connection(conn.url) logging.debug("ChunkObject: new connection open (%r, %r)" % (parsed, self.chunkable_http)) path = '%s/%s/%s' % ( parsed.path.rstrip('/'), quote(smart_str(container)), quote(smart_str(name)), ) headers = { 'X-Auth-Token': conn.token, 'Content-Type': content_type or 'application/octet-stream', 'Transfer-Encoding': 'chunked', # User-Agent ? } if conn.real_ip: headers['X-Forwarded-For'] = conn.real_ip self.chunkable_http.putrequest('PUT', path) for key, value in headers.iteritems(): self.chunkable_http.putheader(key, value) self.chunkable_http.endheaders() logging.debug("ChunkedObject: path=%r, headers=%r" % (path, headers))
def __init__(self, conn, container, name, content_type=None): # FIXME # self._name_check() parsed, self.chunkable_http = http_connection(conn.url) logging.debug("ChunkObject: new connection open (%r, %r)" % (parsed, self.chunkable_http)) path = '%s/%s/%s' % (parsed.path.rstrip('/'), quote(smart_str(container)), quote(smart_str(name)), ) headers = { 'X-Auth-Token': conn.token, 'Content-Type': content_type or 'application/octet-stream', 'Transfer-Encoding': 'chunked', # User-Agent ? } if conn.real_ip: headers['X-Forwarded-For'] = conn.real_ip self.chunkable_http.putrequest('PUT', path) for key, value in headers.iteritems(): self.chunkable_http.putheader(key, value) self.chunkable_http.endheaders() logging.debug("ChunkedObject: path=%r, headers=%r" % (path, headers))
def send(self, data): data = smart_str(data) return super(MyDTPHandler, self).send(data)
def list_folder(self, path): return [ paramiko.SFTPAttributes.from_stat(stat, smart_str(leaf)) for leaf, stat in self.fs.listdir_with_stat(path) ]
def canonicalize(self, path): return smart_str(self.fs.abspath(self.fs.normpath(path)))
def send(self, data): data = smart_str(data) return DTPHandler.send(self, data)
def send(self, data): data=smart_str(data) return super(MyDTPHandler, self).send(data)