From 401aa9ddd1091f5b517dce37cd002bc2c37f5ac1 Mon Sep 17 00:00:00 2001 From: Burdette Lamar Date: Thu, 19 Jan 2023 12:58:34 -0600 Subject: [ruby/net-http] [DOC] Header doc (https://github.com/ruby/net-http/pull/104) https://github.com/ruby/net-http/commit/3308362d9b --- lib/net/http/header.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'lib/net') 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 'Authorization' 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 'Proxy-Authorization' 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} -- cgit v1.2.3