Class: Zenrows::Backends::NetHttpClient Private
- Inherits:
-
Object
- Object
- Zenrows::Backends::NetHttpClient
- Defined in:
- lib/zenrows/backends/net_http.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Wrapper around Net::HTTP that mimics http.rb interface
Instance Method Summary collapse
-
#get(url, **options) ⇒ NetHttpResponse
private
Make GET request.
-
#initialize(proxy_config:, headers:, timeouts:, ssl_context:) ⇒ NetHttpClient
constructor
private
A new instance of NetHttpClient.
-
#post(url, body: nil, **options) ⇒ NetHttpResponse
private
Make POST request.
Constructor Details
#initialize(proxy_config:, headers:, timeouts:, ssl_context:) ⇒ NetHttpClient
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of NetHttpClient.
60 61 62 63 64 65 |
# File 'lib/zenrows/backends/net_http.rb', line 60 def initialize(proxy_config:, headers:, timeouts:, ssl_context:) @proxy_config = proxy_config @headers = headers @timeouts = timeouts @ssl_context = ssl_context end |
Instance Method Details
#get(url, **options) ⇒ NetHttpResponse
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Make GET request
72 73 74 75 |
# File 'lib/zenrows/backends/net_http.rb', line 72 def get(url, **) uri = URI.parse(url) request(uri, Net::HTTP::Get.new(uri), ) end |
#post(url, body: nil, **options) ⇒ NetHttpResponse
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Make POST request
83 84 85 86 87 88 |
# File 'lib/zenrows/backends/net_http.rb', line 83 def post(url, body: nil, **) uri = URI.parse(url) req = Net::HTTP::Post.new(uri) req.body = body if body request(uri, req, ) end |