新手问题 如何直接设置 req 的 Authorization

macknight · March 01, 2015 · Last by macknight replied at March 01, 2015 · 1806 hits

uri = URI('http://example.com/index.html?key=value')

req = Net::HTTP::Get.new(uri.request_uri) req.basic_auth 'user', 'pass'

这样可以设置 req 的 Authorization 的 header 字段 但是我如果想直接设置,如何做呢? req.authoriaztion = 'xxx' 吗?

我设置完如何查看呢? 我用 req.inspect 也没用

找到答案了 直接设置 req['authorization']

You need to Sign in before reply, if you don't have an account, please Sign up first.