lib/auth0/mixins/httpproxy.rb in auth0-5.12.0 vs lib/auth0/mixins/httpproxy.rb in auth0-5.13.0

- old
+ new

@@ -14,11 +14,11 @@ MAX_REQUEST_RETRY_DELAY = 1000 MIN_REQUEST_RETRY_DELAY = 250 BASE_DELAY = 100 # proxying requests from instance methods to HTTP class methods - %i(get post post_file put patch delete delete_with_body).each do |method| + %i(get post post_file post_form put patch delete delete_with_body).each do |method| define_method(method) do |uri, body = {}, extra_headers = {}| body = body.delete_if { |_, v| v.nil? } token = get_token() authorization_header(token) unless token.nil? request_with_retry(method, uri, body, extra_headers) @@ -83,12 +83,15 @@ elsif method == :delete_with_body call(:delete, encode_uri(uri), timeout, headers, body.to_json) elsif method == :post_file body.merge!(multipart: true) # Ignore the default Content-Type headers and let the HTTP client define them - post_file_headers = headers.slice(*headers.keys - ['Content-Type']) + post_file_headers = headers.except('Content-Type') if headers != nil # Actual call with the altered headers call(:post, encode_uri(uri), timeout, post_file_headers, body) + elsif method == :post_form + form_post_headers = headers.except('Content-Type') if headers != nil + call(:post, encode_uri(uri), timeout, form_post_headers, body.compact) else call(method, encode_uri(uri), timeout, headers, body.to_json) end case result.code