From 273117db0b1afeac881e5fb082ca7887dfab07bb Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Wed, 18 Jan 2023 21:33:34 +0000 Subject: [PATCH 1/4] Enhanced RDoc for HTTPHeader --- lib/net/http/header.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/net/http/header.rb b/lib/net/http/header.rb index ab744f5f..59cc4eda 100644 --- a/lib/net/http/header.rb +++ b/lib/net/http/header.rb @@ -923,13 +923,22 @@ def set_form(params, enctype='application/x-www-form-urlencoded', formopt={}) 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') + # # => ["Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA=="] + # def basic_auth(account, password) @header['authorization'] = [basic_encode(account, password)] end - # Set Proxy-Authorization: header for "Basic" authorization. - def proxy_basic_auth(account, password) + # Sets header 'Proxy-Authorization' using the given + # +account+ and +password+ strings: + # + # req.proxy_basic_auth('my_account', 'my_password') + # # => ["Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA=="] + # @header['proxy-authorization'] = [basic_encode(account, password)] end @@ -938,6 +947,7 @@ def basic_encode(account, password) 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 +955,7 @@ def connection_close? 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} From 4f5819f323eb0163d0da0ff940afeb7cebda8ebd Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Wed, 18 Jan 2023 21:39:14 +0000 Subject: [PATCH 2/4] Enhanced RDoc for HTTPHeader --- lib/net/http/header.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/net/http/header.rb b/lib/net/http/header.rb index 59cc4eda..7a67d708 100644 --- a/lib/net/http/header.rb +++ b/lib/net/http/header.rb @@ -939,6 +939,7 @@ def basic_auth(account, password) # req.proxy_basic_auth('my_account', 'my_password') # # => ["Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA=="] # + def proxy_basic_auth(account, password) @header['proxy-authorization'] = [basic_encode(account, password)] end From 6d58021bada17662d02d64a6842e4471a43b08c3 Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Thu, 19 Jan 2023 16:25:43 +0000 Subject: [PATCH 3/4] Enhanced RDoc for HTTPHeader --- lib/net/http/header.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/net/http/header.rb b/lib/net/http/header.rb index 7a67d708..d61ba0d8 100644 --- a/lib/net/http/header.rb +++ b/lib/net/http/header.rb @@ -927,7 +927,7 @@ def set_form(params, enctype='application/x-www-form-urlencoded', formopt={}) # +account+ and +password+ strings: # # req.basic_auth('my_account', 'my_password') - # # => ["Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA=="] + # req['Authorization'] # => ["Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA=="] # def basic_auth(account, password) @header['authorization'] = [basic_encode(account, password)] @@ -937,7 +937,7 @@ def basic_auth(account, password) # +account+ and +password+ strings: # # req.proxy_basic_auth('my_account', 'my_password') - # # => ["Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA=="] + # req['Proxy-Authorization'] # => ["Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA=="] # def proxy_basic_auth(account, password) @header['proxy-authorization'] = [basic_encode(account, password)] From 7a0c95f43507dae26b9aa745d5f5bf6f7441e212 Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Thu, 19 Jan 2023 17:31:36 +0000 Subject: [PATCH 4/4] Enhanced RDoc for HTTPHeader --- lib/net/http/header.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/net/http/header.rb b/lib/net/http/header.rb index d61ba0d8..ef6f32b8 100644 --- a/lib/net/http/header.rb +++ b/lib/net/http/header.rb @@ -927,7 +927,8 @@ def set_form(params, enctype='application/x-www-form-urlencoded', formopt={}) # +account+ and +password+ strings: # # req.basic_auth('my_account', 'my_password') - # req['Authorization'] # => ["Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA=="] + # req['Authorization'] + # # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA==" # def basic_auth(account, password) @header['authorization'] = [basic_encode(account, password)] @@ -937,7 +938,8 @@ def basic_auth(account, password) # +account+ and +password+ strings: # # req.proxy_basic_auth('my_account', 'my_password') - # req['Proxy-Authorization'] # => ["Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA=="] + # req['Proxy-Authorization'] + # # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA==" # def proxy_basic_auth(account, password) @header['proxy-authorization'] = [basic_encode(account, password)]