lib/spark_api/request.rb in spark_api-1.5.2 vs lib/spark_api/request.rb in spark_api-1.5.3
- old
+ new
@@ -59,9 +59,25 @@
# Perform an HTTP request (no data)
def request(method, path, body, options)
unless authenticated?
authenticate
end
+
+ # Allow use of the X-HTTP-Method-Override header to disguise excessively
+ # large GET/DELETE/HEAD requests as POST requests.
+ if options[:http_method_override]
+ options = options.clone
+ options.delete(:http_method_override)
+ body = URI.encode_www_form(options)
+ options = {
+ override_headers: {
+ "X-HTTP-Method-Override" => method.to_s.upcase,
+ "Content-Type" => "application/x-www-form-urlencoded"
+ }
+ }
+ method = :post
+ end
+
attempts = 0
begin
request_opts = {}
request_opts.merge!(options)
request_path = if middleware && middleware.to_sym == :reso_api