[ruby/net-http] [DOC] Header doc
(https://github.com/ruby/net-http/pull/104) https://github.com/ruby/net-http/commit/3308362d9b
This commit is contained in:
parent
762a3d80f7
commit
401aa9ddd1
@ -923,12 +923,24 @@ module Net::HTTPHeader
|
|||||||
end
|
end
|
||||||
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)
|
def basic_auth(account, password)
|
||||||
@header['authorization'] = [basic_encode(account, password)]
|
@header['authorization'] = [basic_encode(account, password)]
|
||||||
end
|
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)
|
def proxy_basic_auth(account, password)
|
||||||
@header['proxy-authorization'] = [basic_encode(account, password)]
|
@header['proxy-authorization'] = [basic_encode(account, password)]
|
||||||
end
|
end
|
||||||
@ -938,6 +950,7 @@ module Net::HTTPHeader
|
|||||||
end
|
end
|
||||||
private :basic_encode
|
private :basic_encode
|
||||||
|
|
||||||
|
# Returns whether the HTTP session is to be closed.
|
||||||
def connection_close?
|
def connection_close?
|
||||||
token = /(?:\A|,)\s*close\s*(?:\z|,)/i
|
token = /(?:\A|,)\s*close\s*(?:\z|,)/i
|
||||||
@header['connection']&.grep(token) {return true}
|
@header['connection']&.grep(token) {return true}
|
||||||
@ -945,6 +958,7 @@ module Net::HTTPHeader
|
|||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns whether the HTTP session is to be kept alive.
|
||||||
def connection_keep_alive?
|
def connection_keep_alive?
|
||||||
token = /(?:\A|,)\s*keep-alive\s*(?:\z|,)/i
|
token = /(?:\A|,)\s*keep-alive\s*(?:\z|,)/i
|
||||||
@header['connection']&.grep(token) {return true}
|
@header['connection']&.grep(token) {return true}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user