def __init__(self, url, pool_size=None, context=None, ehlo_as=None, timeout=None, idle_timeout=None): super(HttpRelay, self).__init__(pool_size) self.url = urlparse.urlsplit(url, 'http') self.context = context self.ehlo_as = ehlo_as or getfqdn() self.timeout = timeout self.idle_timeout = idle_timeout
class FakeRelay(object): queue = self.queue idle_timeout = None url = urlparse.urlsplit('http://testurl:8025/path/info') tls = None http_verb = 'POST' sender_header = 'X-Envelope-Sender' recipient_header = 'X-Envelope-Recipient' ehlo_header = 'X-Ehlo' ehlo_as = 'test' timeout = 10.0 idle_timeout = 10.0
def get_connection(url, tls=None): """This convenience functions returns a :class:`HTTPConnection` or :class:`HTTPSConnection` based on the information contained in URL. :param url: URL string to create a connection for. Alternatively, passing in the results of :py:func:`urlparse.urlsplit` works as well. :param tls: When the URL scheme is ``https``, this is passed in as the ``tls`` parameter to :class:`HTTPSConnection`. """ if isinstance(url, (str, bytes)): url = urlparse.urlsplit(url, 'http') host = url.netloc or 'localhost' if url.scheme == 'https': conn = HTTPSConnection(host, tls=tls) else: conn = HTTPConnection(host) return conn
def get_connection(url, context=None): """This convenience functions returns a :class:`HTTPConnection` or :class:`HTTPSConnection` based on the information contained in URL. :param url: URL string to create a connection for. Alternatively, passing in the results of :py:func:`urlparse.urlsplit` works as well. :param context: Used to wrap sockets with SSL encryption, when the URL scheme is ``https``. :type context: :py:class:`~ssl.SSLContext` """ if isinstance(url, (str, bytes)): url = urlparse.urlsplit(url, 'http') host = url.netloc or 'localhost' if url.scheme == 'https': conn = HTTPSConnection(host, context=context) else: conn = HTTPConnection(host) return conn