@@ -923,12 +923,24 @@ def set_form(params, enctype='application/x-www-form-urlencoded', formopt={})
923
923
end
924
924
end
925
925
926
- # Set the Authorization: header for "Basic" authorization.
926
+ # Sets header <tt>'Authorization'</tt> using the given
927
+ # +account+ and +password+ strings:
928
+ #
929
+ # req.basic_auth('my_account', 'my_password')
930
+ # req['Authorization']
931
+ # # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA=="
932
+ #
927
933
def basic_auth ( account , password )
928
934
@header [ 'authorization' ] = [ basic_encode ( account , password ) ]
929
935
end
930
936
931
- # Set Proxy-Authorization: header for "Basic" authorization.
937
+ # Sets header <tt>'Proxy-Authorization'</tt> using the given
938
+ # +account+ and +password+ strings:
939
+ #
940
+ # req.proxy_basic_auth('my_account', 'my_password')
941
+ # req['Proxy-Authorization']
942
+ # # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA=="
943
+ #
932
944
def proxy_basic_auth ( account , password )
933
945
@header [ 'proxy-authorization' ] = [ basic_encode ( account , password ) ]
934
946
end
@@ -938,13 +950,15 @@ def basic_encode(account, password)
938
950
end
939
951
private :basic_encode
940
952
953
+ # Returns whether the HTTP session is to be closed.
941
954
def connection_close?
942
955
token = /(?:\A |,)\s *close\s *(?:\z |,)/i
943
956
@header [ 'connection' ] &.grep ( token ) { return true }
944
957
@header [ 'proxy-connection' ] &.grep ( token ) { return true }
945
958
false
946
959
end
947
960
961
+ # Returns whether the HTTP session is to be kept alive.
948
962
def connection_keep_alive?
949
963
token = /(?:\A |,)\s *keep-alive\s *(?:\z |,)/i
950
964
@header [ 'connection' ] &.grep ( token ) { return true }
0 commit comments