Module: ProxyFetcher::Client

Defined in:
lib/proxy_fetcher/client/client.rb,
lib/proxy_fetcher/client/request.rb,
lib/proxy_fetcher/client/proxies_registry.rb

Overview

ProxyFetcher HTTP client that encapsulates all the logic for sending HTTP(S) requests using proxies, automatically fetched and validated by the gem.

Defined Under Namespace

Classes: ProxiesRegistry, Request

Class Method Summary collapse

Class Method Details

.delete(url, headers: {}, options: {}) ⇒ String

Sends HTTP DELETE request.

Parameters:

  • url (String)

    Requested URL

  • headers (Hash) (defaults to: {})

    HTTP headers that will be used in the request

  • options (Hash) (defaults to: {})

    Additional options used by ProxyFetcher::Client

Returns:

  • (String)

    HTML body from the URL.



79
80
81
# File 'lib/proxy_fetcher/client/client.rb', line 79

def delete(url, headers: {}, options: {})
  request_without_payload(:delete, url, headers, options)
end

.get(url, headers: {}, options: {}) ⇒ String

Sends HTTP GET request.

Parameters:

  • url (String)

    Requested URL

  • headers (Hash) (defaults to: {})

    HTTP headers that will be used in the request

  • options (Hash) (defaults to: {})

    Additional options used by ProxyFetcher::Client

Returns:

  • (String)

    HTML body from the URL.



22
23
24
# File 'lib/proxy_fetcher/client/client.rb', line 22

def get(url, headers: {}, options: {})
  request_without_payload(:get, url, headers, options)
end

.head(url, headers: {}, options: {}) ⇒ String

Sends HTTP HEAD request.

Parameters:

  • url (String)

    Requested URL

  • headers (Hash) (defaults to: {})

    HTTP headers that will be used in the request

  • options (Hash) (defaults to: {})

    Additional options used by ProxyFetcher::Client

Returns:

  • (String)

    HTML body from the URL.



40
41
42
# File 'lib/proxy_fetcher/client/client.rb', line 40

def head(url, headers: {}, options: {})
  request_without_payload(:head, url, headers, options)
end

.patch(url, payload, headers: {}, options: {}) ⇒ String

Sends HTTP PATCH request.

Parameters:

  • url (String)

    Requested URL

  • payload (String, Hash)

    HTTP payload

  • headers (Hash) (defaults to: {})

    HTTP headers that will be used in the request

  • options (Hash) (defaults to: {})

    Additional options used by ProxyFetcher::Client

Returns:

  • (String)

    HTML body from the URL.



121
122
123
# File 'lib/proxy_fetcher/client/client.rb', line 121

def patch(url, payload, headers: {}, options: {})
  request_with_payload(:patch, url, payload, headers, options)
end

.post(url, payload, headers: {}, options: {}) ⇒ String

Sends HTTP POST request.

Parameters:

  • url (String)

    Requested URL

  • payload (String, Hash)

    HTTP payload

  • headers (Hash) (defaults to: {})

    HTTP headers that will be used in the request

  • options (Hash) (defaults to: {})

    Additional options used by ProxyFetcher::Client

Returns:

  • (String)

    HTML body from the URL.



61
62
63
# File 'lib/proxy_fetcher/client/client.rb', line 61

def post(url, payload, headers: {}, options: {})
  request_with_payload(:post, url, payload, headers, options)
end

.put(url, payload, headers: {}, options: {}) ⇒ String

Sends HTTP PUT request.

Parameters:

  • url (String)

    Requested URL

  • payload (String, Hash)

    HTTP payload

  • headers (Hash) (defaults to: {})

    HTTP headers that will be used in the request

  • options (Hash) (defaults to: {})

    Additional options used by ProxyFetcher::Client

Returns:

  • (String)

    HTML body from the URL.



100
101
102
# File 'lib/proxy_fetcher/client/client.rb', line 100

def put(url, payload, headers: {}, options: {})
  request_with_payload(:put, url, payload, headers, options)
end