Вот последняя попытка этого поста:
Когда я пытаюсь сделать вызов, используя rest-client в потоке, он завершается неудачно и рано покидает поток.Когда я запускаю его вне потока, все нормально.
Есть идеи?
require 'base64'
require 'json'
require 'rest-client'
require 'thwait'
test = Thread.new {
endpoint = "http://my/url"
headers = {'Authorization' => "Basic #{Base64.encode64("username:password")}", 'Accept' => 'Application/json', 'Content-Type' => 'Application/json'}
payload = JSON.parse("{\"documents\": { \"textField1\":\"asdf\" }}").to_json
# See the results of the above. Successful now (headers hash with expected encoded value, JSON string as expected)
puts headers
puts payload
# Expecting REST response on the console. Nothing appears on the console.
puts RestClient::Request.execute(:method => :post, :url => endpoint, :headers => headers, :payload => payload, :verify_ssl => false)
# Expecting simple text output to the console to see if execution reaches this point. Nothing appears on the console.
puts 'done'
}
# Where this is actually being used, ThreadsWait is used for thread management, so simulating that here
thwait = ThreadsWait.new(test)
thwait.next_wait