例如,在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導致內容類型得到尊重,但顯然這不是真正的解決方案。有誰知道解決這個問題的正確方法?謝謝。
謝謝,這工作正常。 –