例如,在 RestClient 控制台中:
RestClient.post 'http://localhost:5001', {:a => 'b'}, :content_type => 'application/json'
这不会发送 application/json 作为内容类型。相反,我看到:
Content-Type: application/x-www-form-urlencoded
我能够跟踪到 restclient/payload.rb 的更改:
class UrlEncoded < Base
...
def headers
super.merge({'Content-Type' => 'application/x-www-form-urlencoded'})
end
end
用 super 替换 super.merge 会导致内容类型受到尊重,但显然这不是一个真正的解决方案。有谁知道解决这个问题的正确方法?谢谢。