如何解决如何使用RestClient Ruby gem发送代理用户名和密码
根据我们可以添加代理的文档,我正在使用RestClient gem作为发布请求,但是在我的情况下,代理URL本身具有身份验证,如何使用Restclient Gem来实现
RestClient.proxy = "someurl"
RestClient.proxy_user_name = ??
RestClient.proxy_password = ??
request = RestClient::Request.new(
:method => :post,:url => 'some_url',:user => '123',:password => '123',:payload => {
:multipart => true,:file => File.new("somepath",'rb')
}
)
response = request.execute
解决方法
可以像这样使用RestClient::Request.execute
:
RestClient::Request.execute(
method: :post,url: 'some_url',proxy: 'https://username:password@proxy_url:proxy_port' # will be parsed with URI.parse
)
在此处检查文档:rest-client
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。