Standardize transport initialization/options (Fixes GH-608)
This commit is contained in:
parent
824e48761b
commit
6f81614e66
|
@ -26,15 +26,13 @@ class GeventedHTTPTransport(AsyncTransport, HTTPTransport):
|
|||
|
||||
scheme = ['gevent+http', 'gevent+https']
|
||||
|
||||
def __init__(self, parsed_url, maximum_outstanding_requests=100):
|
||||
def __init__(self, parsed_url, maximum_outstanding_requests=100, *args, **kwargs):
|
||||
if not has_gevent:
|
||||
raise ImportError('GeventedHTTPTransport requires gevent.')
|
||||
|
||||
self._lock = Semaphore(maximum_outstanding_requests)
|
||||
|
||||
super(GeventedHTTPTransport, self).__init__(parsed_url)
|
||||
|
||||
# remove the gevent+ from the protocol, as it is not a real protocol
|
||||
self._url = self._url.split('+', 1)[-1]
|
||||
super(GeventedHTTPTransport, self).__init__(parsed_url, *args, **kwargs)
|
||||
|
||||
def async_send(self, data, headers, success_cb, failure_cb):
|
||||
"""
|
||||
|
|
|
@ -23,7 +23,7 @@ class HTTPTransport(Transport):
|
|||
self.check_scheme(parsed_url)
|
||||
|
||||
self._parsed_url = parsed_url
|
||||
self._url = parsed_url.geturl().split('+', 1)[-1]
|
||||
self._url = parsed_url.geturl().rsplit('+', 1)[-1]
|
||||
|
||||
if isinstance(timeout, six.string_types):
|
||||
timeout = int(timeout)
|
||||
|
|
|
@ -7,7 +7,6 @@ raven.transport.requests
|
|||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
from raven.conf import defaults
|
||||
from raven.transport.http import HTTPTransport
|
||||
|
||||
try:
|
||||
|
@ -21,18 +20,11 @@ class RequestsHTTPTransport(HTTPTransport):
|
|||
|
||||
scheme = ['requests+http', 'requests+https']
|
||||
|
||||
def __init__(self, parsed_url, timeout=defaults.TIMEOUT, verify_ssl=True,
|
||||
ca_certs=defaults.CA_BUNDLE):
|
||||
def __init__(self, *args, **kwargs):
|
||||
if not has_requests:
|
||||
raise ImportError('RequestsHTTPTransport requires requests.')
|
||||
|
||||
super(RequestsHTTPTransport, self).__init__(parsed_url,
|
||||
timeout=timeout,
|
||||
verify_ssl=verify_ssl,
|
||||
ca_certs=ca_certs)
|
||||
|
||||
# remove the requests+ from the protocol, as it is not a real protocol
|
||||
self._url = self._url.split('+', 1)[-1]
|
||||
super(RequestsHTTPTransport, self).__init__(*args, **kwargs)
|
||||
|
||||
def send(self, data, headers):
|
||||
if self.verify_ssl:
|
||||
|
|
|
@ -21,14 +21,11 @@ class TornadoHTTPTransport(HTTPTransport):
|
|||
|
||||
scheme = ['tornado+http', 'tornado+https']
|
||||
|
||||
def __init__(self, parsed_url, **kwargs):
|
||||
def __init__(self, parsed_url, *args, **kwargs):
|
||||
if not has_tornado:
|
||||
raise ImportError('TornadoHTTPTransport requires tornado.')
|
||||
|
||||
super(TornadoHTTPTransport, self).__init__(parsed_url, **kwargs)
|
||||
|
||||
# remove the tornado+ from the protocol, as it is not a real protocol
|
||||
self._url = self._url.split('+', 1)[-1]
|
||||
super(TornadoHTTPTransport, self).__init__(parsed_url, *args, **kwargs)
|
||||
|
||||
def send(self, data, headers):
|
||||
kwargs = dict(method='POST', headers=headers, body=data)
|
||||
|
|
|
@ -8,7 +8,6 @@ raven.transport.twisted
|
|||
from __future__ import absolute_import
|
||||
|
||||
import io
|
||||
import logging
|
||||
|
||||
from raven.transport.base import AsyncTransport
|
||||
from raven.transport.http import HTTPTransport
|
||||
|
@ -25,18 +24,13 @@ except:
|
|||
|
||||
|
||||
class TwistedHTTPTransport(AsyncTransport, HTTPTransport):
|
||||
|
||||
scheme = ['twisted+http', 'twisted+https']
|
||||
|
||||
def __init__(self, parsed_url):
|
||||
def __init__(self, parsed_url, *args, **kwargs):
|
||||
if not has_twisted:
|
||||
raise ImportError('TwistedHTTPTransport requires twisted.web.')
|
||||
|
||||
super(TwistedHTTPTransport, self).__init__(parsed_url)
|
||||
self.logger = logging.getLogger('sentry.errors')
|
||||
|
||||
# remove the twisted+ from the protocol, as it is not a real protocol
|
||||
self._url = self._url.split('+', 1)[-1]
|
||||
super(TwistedHTTPTransport, self).__init__(*args, **kwargs)
|
||||
|
||||
# Import reactor as late as possible.
|
||||
from twisted.internet import reactor
|
||||
|
|
Loading…
Reference in New Issue