Class: Maze::Repeaters::RequestRepeater
- Inherits:
-
Object
- Object
- Maze::Repeaters::RequestRepeater
- Defined in:
- lib/maze/repeaters/request_repeater.rb
Overview
Repeats POST requests
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(request_type) ⇒ RequestRepeater
constructor
A new instance of RequestRepeater.
- #repeat(request) ⇒ Object
Constructor Details
#initialize(request_type) ⇒ RequestRepeater
Returns a new instance of RequestRepeater.
6 7 8 |
# File 'lib/maze/repeaters/request_repeater.rb', line 6 def initialize(request_type) @request_type = request_type end |
Instance Method Details
#repeat(request) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/maze/repeaters/request_repeater.rb', line 11 def repeat(request) return unless enabled? # TODO Forwarding of internal errors to be considered later return if request.header.keys.any? { |key| key.downcase == 'bugsnag-internal-error' } uri = url_for_request_type Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |https| onward_request = Net::HTTP::Post.new(uri.path) onward_request.body = decompress(request) # Set all headers that are present, unless Gzip is not supported request.header.each do |key,value| # Only include content-type header if gip is supported next if !gzip_supported && key.downcase == 'content-encoding' # All other headers are opt-in to avoid accidental leakage next unless include_header? key.downcase, value onward_request[key] = value end # Set headers specific to the repeater set_headers onward_request response = https.request(onward_request) log_response response end end |