lib/soaspec/exchange_handlers/rest_handler.rb in soaspec-0.0.60 vs lib/soaspec/exchange_handlers/rest_handler.rb in soaspec-0.0.61

- old
+ new

@@ -39,13 +39,20 @@ grant_type: 'client_credentials', client_id: client_id, client_secret: client_secret } end - response = RestClient.post(token_url, payload, cache_control: 'no_cache', verify_ssl: false) - Soaspec::SpecLogger.add_to 'request_params: ' + payload.to_s - Soaspec::SpecLogger.add_to('response_headers: ' + response.headers.to_s) - Soaspec::SpecLogger.add_to('response_body: ' + response.to_s) + retry_count = 0 + begin + Soaspec::SpecLogger.add_to 'request_params: ' + payload.to_s + response = RestClient.post(token_url, payload, cache_control: 'no_cache', verify_ssl: false) + rescue RestClient::Exception => e + retry_count += 1 + retry if retry_count < 3 + raise e + end + Soaspec::SpecLogger.add_to("response_headers: #{response.headers}") + Soaspec::SpecLogger.add_to("response_body: #{response.body}") JSON.parse(response) end define_method('access_token') do oauth_response['access_token'] \ No newline at end of file