Sha256: 208ac662a65ac45a55796275a1cda5e20c3815147d96a995b2d7b42cbfc9126e

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

require 'faraday'

require 'raven/transports'
require 'raven/error'

module Raven

  module Transports

    class HTTP < Transport

      def send(auth_header, data, options = {})
        response = conn.post '/api/store/' do |req|
          req.headers['Content-Type'] = options[:content_type]
          req.headers['X-Sentry-Auth'] = auth_header
          req.body = data
        end
        Raven.logger.warn "Error from Sentry server (#{response.status}): #{response.body}" unless response.status == 200
      end

    private

      def conn
        @conn ||= begin
          self.verify_configuration

          Raven.logger.debug "Raven HTTP Transport connecting to #{self.configuration.server}"

          conn = Faraday.new(
            :url => self.configuration[:server],
            :ssl => {:verify => self.configuration.ssl_verification}
          ) do |builder|
            builder.adapter(*adapter)
          end

          if self.configuration.timeout
            conn.options[:timeout] = self.configuration.timeout
          end
          if self.configuration.open_timeout
            conn.options[:open_timeout] = self.configuration.open_timeout
          end

          conn
        end
      end

      def adapter
        configuration.http_adapter || Faraday.default_adapter
      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sentry-raven-0.4.5 lib/raven/transports/http.rb