According to the discussion here, the net-http gem will no longer set a default content type. (From v0.7.0)
# Previous
set_content_type 'application/x-www-form-urlencoded'
# New
n/a
Impact
This might change the behavior of HTTP requests that directly or indirectly (E.g., httparty) rely on the net-http gem.
Example: Google Recaptcha API
# Works previously
post("https://www.google.com/recaptcha/api/siteverify", body: { secret: secret_key, response: token, remoteip: remote_ip })
=> {"success" => true, "challenge_ts" => "...", "hostname" => "...", "score" => 0.9, "action" => "login"}
# Fails after upgrading net-http gem
post("https://www.google.com/recaptcha/api/siteverify", body: { secret: secret_key, response: token, remoteip: remote_ip })
=> {"success" => false, "error-codes" => ["invalid-input-response"]}
Solution
Always set your Content-Type header and do not rely on the default behavior.
post("https://www.google.com/recaptcha/api/siteverify",
body: { secret: secret_key, response: token, remoteip: remote_ip },
headers: { "Content-Type" => "application/x-www-form-urlencoded" }
)