module HTTPX::Plugins::SsrfFilter::InstanceMethods

  1. lib/httpx/plugins/ssrf_filter.rb

Methods

Public Instance

  1. send_requests

Public Instance methods

send_requests(*requests)
[show source]
    # File lib/httpx/plugins/ssrf_filter.rb
100 def send_requests(*requests)
101   responses = requests.map do |request|
102     next if @options.allowed_schemes.include?(request.uri.scheme)
103 
104     error = ServerSideRequestForgeryError.new("#{request.uri} URI scheme not allowed")
105     error.set_backtrace(caller)
106     response = ErrorResponse.new(request, error)
107     request.emit(:response, response)
108     response
109   end
110   allowed_requests = requests.select { |req| responses[requests.index(req)].nil? }
111   allowed_responses = super(*allowed_requests)
112   allowed_responses.each_with_index do |res, idx|
113     req = allowed_requests[idx]
114     responses[requests.index(req)] = res
115   end
116 
117   responses
118 end