Skip to content
This repository was archived by the owner on Oct 22, 2020. It is now read-only.

Commit 12d9db8

Browse files
committed
Fix null reference in #queue_request
1 parent 90fff83 commit 12d9db8

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

lib/wpxf/net/http_client.rb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ def initialize
1414

1515
initialize_options
1616
initialize_advanced_options
17+
18+
@hydra = Typhoeus::Hydra.new(max_concurrency: max_http_concurrency)
1719
end
1820

1921
# Initialize the basic HTTP options for the module.
@@ -106,6 +108,7 @@ def queue_request(opts, &callback)
106108
end
107109

108110
@hydra.queue req
111+
@hydra.queued_requests
109112
end
110113

111114
# Execute multiple HTTP requests in parallel queued by {#queue_request}.
@@ -179,13 +182,6 @@ def execute_delete_request(opts)
179182
def max_http_concurrency
180183
normalized_option_value('max_http_concurrency')
181184
end
182-
183-
# Run the module.
184-
# @return [Boolean] true if the module was successful.
185-
def run
186-
super
187-
@hydra = Typhoeus::Hydra.new(max_concurrency: max_http_concurrency)
188-
end
189185
end
190186
end
191187
end

spec/net/http_client_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,4 +342,12 @@
342342
expect(res.headers).to eq typhoeus_headers
343343
end
344344
end
345+
346+
describe '#queue_request' do
347+
it 'queues a request to be made later by #execute_queued_requests' do
348+
subject.queue_request(url: 'http://127.0.0.1/foo')
349+
queue = subject.queue_request(url: 'http://127.0.0.1/bar')
350+
expect(queue.length).to eq 2
351+
end
352+
end
345353
end

0 commit comments

Comments
 (0)