例如,在RESTClient实现控制台:如何在后期制作Ruby的RestClient gem尊重content_type?
RestClient.post 'http://localhost:5001', {:a => 'b'}, :content_type => 'application/json'
这不会发送应用程序/ 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.merge导致内容类型得到尊重,但显然这不是真正的解决方案。有谁知道解决这个问题的正确方法?谢谢。
谢谢,这工作正常。 –