Package restkit :: Package conn :: Module http_connection
[hide private]
[frames] | no frames]

Source Code for Module restkit.conn.http_connection

 1  # -*- coding: utf-8 - 
 2  # 
 3  # This file is part of restkit released under the MIT license.  
 4  # See the NOTICE for more information. 
 5   
 6  import copy 
 7  import socket 
 8   
 9  from restkit.util import sock 
10   
11 -class HttpConnection(object):
12
13 - def __init__(self, conn_manager,addr, is_ssl, timeout=300, 14 filters=None, **ssl_args):
15 self.conn_manager = conn_manager 16 self.filters = copy.copy(filters) 17 self.addr = addr 18 self.is_ssl = is_ssl 19 self.timeout = timeout 20 self.ssl_args = ssl_args or {} 21 self.headers = [] 22 self.params = {} 23 self.sock = None 24 self.connect()
25
26 - def connect(self):
27 self.filters.apply("on_connect", self) 28 29 self.sock = sock.connect(self.addr, self.is_ssl, 30 self.timeout, **self.ssl_args)
31 32 33
34 - def socket(self):
35 return self.sock
36
37 - def close(self):
38 sock.close(self.sock)
39