Class: HttpClient
- Inherits:
-
Object
- Object
- HttpClient
- Defined in:
- lib/fingerprinter/core/http_client.rb
Overview
HTTP Client used to perform some requests (check for some content for example) or as a fallback in some browser processing (less resource intensive than using a Chrome instance but won’t provide access to the DOM for example)
Instance Method Summary collapse
- #get(url, options = {}) ⇒ Object
-
#initialize ⇒ HttpClient
constructor
A new instance of HttpClient.
- #request_options(method, options, body = nil) ⇒ Object
Constructor Details
#initialize ⇒ HttpClient
Returns a new instance of HttpClient.
9 10 11 |
# File 'lib/fingerprinter/core/http_client.rb', line 9 def initialize Typhoeus::Config.user_agent = ScanOptions.user_agent end |
Instance Method Details
#get(url, options = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/fingerprinter/core/http_client.rb', line 37 def get(url, = {}) responses = {} http_request = Typhoeus::Request.new(url, (:get, )) http_request.on_complete { |response| responses[url] = response } http_request.run responses end |
#request_options(method, options, body = nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fingerprinter/core/http_client.rb', line 13 def (method, , body = nil) = { ssl_verifypeer: false, ssl_verifyhost: 0, followlocation: [:follow_location] || false, method: method, headers: [:headers] || {}, body: body } [:headers].merge!({ 'Priority' => 'u=0, i', 'Accept-Encoding' => 'gzip, deflate, br', 'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8' }) [:params] = [:params] if [:params] [:proxy] = ScanOptions.proxy_url if ScanOptions.proxy? [:timeout] = ScanOptions.timeout end |