from __future__ import absolute_import

from raven.transport.http import HTTPTransport

try:
    import requests
    has_requests = True
except:
    has_requests = False


class RequestsHTTPTransport(HTTPTransport):

    scheme = ['requests+http', 'requests+https']

    def __init__(self, parsed_url):
        if not has_requests:
            raise ImportError('RequestsHTTPTransport requires requests.')

        super(RequestsHTTPTransport, self).__init__(parsed_url)

        # remove the requests+ from the protocol, as it is not a real protocol
        self._url = self._url.split('+', 1)[-1]

    def send(self, data, headers):
        requests.post(self._url, data=data, headers=headers)

from __future__ import absolute_import

from raven.conf import defaults
from raven.transport.http import HTTPTransport

try:
    import requests
    has_requests = True
except:
    has_requests = False


class RequestsHTTPTransport(HTTPTransport):

    scheme = ['requests+http', 'requests+https']

    def __init__(self, parsed_url, timeout=defaults.TIMEOUT, verify_ssl=True,
                 ca_certs=defaults.CA_BUNDLE):
        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]

    def send(self, data, headers):
        if self.verify_ssl:
            # If SSL verification is enabled use the provided CA bundle to
            # perform the verification.
            self.verify_ssl = self.ca_certs
        requests.post(self._url, data=data, headers=headers,
                      verify=self.verify_ssl, timeout=self.timeout)

Add support for the verify_ssl, ca_certs and timeout parameters for the request transport.
Add support for the verify_ssl, ca_certs and timeout parameters for the request transport.

  from __future__ import absolute_import
  
+ from raven.conf import defaults
  from raven.transport.http import HTTPTransport
  
  try:
      import requests
      has_requests = True
  except:
      has_requests = False
  
  
  class RequestsHTTPTransport(HTTPTransport):
  
      scheme = ['requests+http', 'requests+https']
  
-     def __init__(self, parsed_url):
+     def __init__(self, parsed_url, timeout=defaults.TIMEOUT, verify_ssl=True,
+                  ca_certs=defaults.CA_BUNDLE):
          if not has_requests:
              raise ImportError('RequestsHTTPTransport requires requests.')
  
-         super(RequestsHTTPTransport, self).__init__(parsed_url)
+         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]
  
      def send(self, data, headers):
+         if self.verify_ssl:
+             # If SSL verification is enabled use the provided CA bundle to
+             # perform the verification.
+             self.verify_ssl = self.ca_certs
-         requests.post(self._url, data=data, headers=headers)
+         requests.post(self._url, data=data, headers=headers,
+                       verify=self.verify_ssl, timeout=self.timeout)
  
Add support for the verify_ssl, ca_certs and timeout parameters for the request transport.
## Code Before:
from __future__ import absolute_import

from raven.transport.http import HTTPTransport

try:
    import requests
    has_requests = True
except:
    has_requests = False


class RequestsHTTPTransport(HTTPTransport):

    scheme = ['requests+http', 'requests+https']

    def __init__(self, parsed_url):
        if not has_requests:
            raise ImportError('RequestsHTTPTransport requires requests.')

        super(RequestsHTTPTransport, self).__init__(parsed_url)

        # remove the requests+ from the protocol, as it is not a real protocol
        self._url = self._url.split('+', 1)[-1]

    def send(self, data, headers):
        requests.post(self._url, data=data, headers=headers)

## Instruction:
Add support for the verify_ssl, ca_certs and timeout parameters for the request transport.
## Code After:
from __future__ import absolute_import

from raven.conf import defaults
from raven.transport.http import HTTPTransport

try:
    import requests
    has_requests = True
except:
    has_requests = False


class RequestsHTTPTransport(HTTPTransport):

    scheme = ['requests+http', 'requests+https']

    def __init__(self, parsed_url, timeout=defaults.TIMEOUT, verify_ssl=True,
                 ca_certs=defaults.CA_BUNDLE):
        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]

    def send(self, data, headers):
        if self.verify_ssl:
            # If SSL verification is enabled use the provided CA bundle to
            # perform the verification.
            self.verify_ssl = self.ca_certs
        requests.post(self._url, data=data, headers=headers,
                      verify=self.verify_ssl, timeout=self.timeout)
