diff options
author | Burdette Lamar <[email protected]> | 2023-01-19 12:58:34 -0600 |
---|---|---|
committer | git <[email protected]> | 2023-01-19 18:58:40 +0000 |
commit | 401aa9ddd1091f5b517dce37cd002bc2c37f5ac1 (patch) | |
tree | 66ba592aab3c2b4aa1f7f40ffc7233d1e3972f3c /lib/net | |
parent | 762a3d80f77db0f96d3e01ccd1cc7b3891f0cfcf (diff) |
[ruby/net-http] [DOC] Header doc
(https://github.com/ruby/net-http/pull/104)
https://github.com/ruby/net-http/commit/3308362d9b
Diffstat (limited to 'lib/net')
-rw-r--r-- | lib/net/http/header.rb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/net/http/header.rb b/lib/net/http/header.rb index 4f3d3fa098..1425b6b329 100644 --- a/lib/net/http/header.rb +++ b/lib/net/http/header.rb @@ -923,12 +923,24 @@ module Net::HTTPHeader end end - # Set the Authorization: header for "Basic" authorization. + # Sets header <tt>'Authorization'</tt> using the given + # +account+ and +password+ strings: + # + # req.basic_auth('my_account', 'my_password') + # req['Authorization'] + # # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA==" + # def basic_auth(account, password) @header['authorization'] = [basic_encode(account, password)] end - # Set Proxy-Authorization: header for "Basic" authorization. + # Sets header <tt>'Proxy-Authorization'</tt> using the given + # +account+ and +password+ strings: + # + # req.proxy_basic_auth('my_account', 'my_password') + # req['Proxy-Authorization'] + # # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA==" + # def proxy_basic_auth(account, password) @header['proxy-authorization'] = [basic_encode(account, password)] end @@ -938,6 +950,7 @@ module Net::HTTPHeader end private :basic_encode +# Returns whether the HTTP session is to be closed. def connection_close? token = /(?:\A|,)\s*close\s*(?:\z|,)/i @header['connection']&.grep(token) {return true} @@ -945,6 +958,7 @@ module Net::HTTPHeader false end +# Returns whether the HTTP session is to be kept alive. def connection_keep_alive? token = /(?:\A|,)\s*keep-alive\s*(?:\z|,)/i @header['connection']&.grep(token) {return true} |