Sha256: 8d2da3ba6a35da8c7104b5e5e5ee6dfeb57e9315ddf14c6aa4825f16ccf648d2

Contents?: true

Size: 1.54 KB

Versions: 5

Compression:

Stored size: 1.54 KB

Contents

require 'faraday'

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

module Raven
  module Transports
    class HTTP < Transport

      def send(auth_header, data, options = {})
        project_id = self.configuration[:project_id]
        path = self.configuration[:path].gsub('/sentry', '') + "/"

        response = conn.post "#{path}api/#{project_id}/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}"

          ssl_configuration = self.configuration.ssl || {}
          ssl_configuration[:verify] = self.configuration.ssl_verification

          conn = Faraday.new(
            :url => self.configuration[:server],
            :ssl => ssl_configuration
          ) 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

5 entries across 5 versions & 2 rubygems

Version Path
sentry-raven-0.12.2 lib/raven/transports/http.rb
sentry-raven-0.12.1 lib/raven/transports/http.rb
sentry-raven-0.12.0 lib/raven/transports/http.rb
mustwin-sentry-raven-0.11.2 lib/raven/transports/http.rb
sentry-raven-0.11.2 lib/raven/transports/http.rb