From aacde25663efb1839431c3f85e604f726bc34cf3 Mon Sep 17 00:00:00 2001 From: Julien Hofstede Date: Tue, 1 Oct 2019 20:31:29 +0200 Subject: [PATCH 1/3] Follow-up URLs from the response should not be re-encoded. --- lib/oktakit/client.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/oktakit/client.rb b/lib/oktakit/client.rb index a9e6266..81a9af3 100644 --- a/lib/oktakit/client.rb +++ b/lib/oktakit/client.rb @@ -72,7 +72,8 @@ def get(url, options = {}) if status == 200 && should_paginate all_objs = [resp] while next_page - resp, status, next_page = request :get, next_page, **request_options + sleep 1 + resp, status, next_page = request :get, next_page, uri_encode_url: false, **request_options break unless status == 200 # Return early if page request fails all_objs << resp @@ -162,14 +163,15 @@ def head(url, options = {}) private - def request(method, path, data:, query:, headers:, accept:, content_type:, paginate: false) + def request(method, path, data:, query:, headers:, accept:, content_type:, paginate: false, uri_encode_url: true) options = {} options[:query] = query || {} options[:headers] = headers || {} options[:headers][:accept] = accept if accept options[:headers][:content_type] = content_type if content_type - uri = URI::DEFAULT_PARSER.escape("/api/v1" + path.to_s) + uri = "/api/v1" + path.to_s + uri = URI::DEFAULT_PARSER.escape(uri) if uri_encode_url @last_response = resp = sawyer_agent.call(method, uri, data, options) response = [resp.data, resp.status] From a727af32fb3ba9822276451e47b8a439cd517511 Mon Sep 17 00:00:00 2001 From: Julien Hofstede Date: Tue, 1 Oct 2019 20:34:33 +0200 Subject: [PATCH 2/3] No sleep for this PR --- lib/oktakit/client.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/oktakit/client.rb b/lib/oktakit/client.rb index 81a9af3..ceae1f3 100644 --- a/lib/oktakit/client.rb +++ b/lib/oktakit/client.rb @@ -72,7 +72,6 @@ def get(url, options = {}) if status == 200 && should_paginate all_objs = [resp] while next_page - sleep 1 resp, status, next_page = request :get, next_page, uri_encode_url: false, **request_options break unless status == 200 # Return early if page request fails From d7712dba1a43d50b5172c44e561b85dd4f164da4 Mon Sep 17 00:00:00 2001 From: Julien Hofstede Date: Mon, 24 Feb 2020 10:45:56 +0100 Subject: [PATCH 3/3] Make sure the client does not cause rate limit warnings. Should be configurable through the options. --- lib/oktakit/client.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/oktakit/client.rb b/lib/oktakit/client.rb index ceae1f3..399f6b1 100644 --- a/lib/oktakit/client.rb +++ b/lib/oktakit/client.rb @@ -72,6 +72,7 @@ def get(url, options = {}) if status == 200 && should_paginate all_objs = [resp] while next_page + sleep 1.5 resp, status, next_page = request :get, next_page, uri_encode_url: false, **request_options break unless status == 200 # Return early if page request fails