Skip to content

Commit

Permalink
Sending the right content type for empty bodies
Browse files Browse the repository at this point in the history
  • Loading branch information
andyjeffries committed Sep 1, 2017
1 parent ad540a8 commit e839be1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/flexirest/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,11 @@ def prepare_request_body(params = nil)
headers["Accept"] ||= "application/vnd.api+json"
JsonAPIProxy::Headers.save(headers)
elsif http_method == :get || (http_method == :delete && !@method[:options][:send_delete_body])
headers["Content-Type"] ||= "application/x-www-form-urlencoded"
if request_body_type == :form_encoded
headers["Content-Type"] ||= "application/x-www-form-urlencoded"
elsif request_body_type == :json
headers["Content-Type"] ||= "application/json; charset=utf-8"
end
@body = ""
elsif request_body_type == :form_encoded
@body ||= (params || @post_params || {}).to_query
Expand Down
2 changes: 1 addition & 1 deletion lib/flexirest/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Flexirest
VERSION = "1.4.7"
VERSION = "1.4.8"
end

0 comments on commit e839be1

Please sign in to comment.