1414import gitlab .config
1515import gitlab .const
1616import gitlab .exceptions
17- from gitlab import utils
17+ from gitlab import http_engines , utils
1818
1919REDIRECT_MSG = (
2020 "python-gitlab detected a {status_code} ({reason!r}) redirection. You must update "
@@ -55,6 +55,8 @@ class Gitlab:
5555 differs from response headers
5656 """
5757
58+ session : requests .Session
59+
5860 def __init__ (
5961 self ,
6062 url : Optional [str ] = None ,
@@ -66,14 +68,20 @@ def __init__(
6668 http_password : Optional [str ] = None ,
6769 timeout : Optional [float ] = None ,
6870 api_version : str = "4" ,
69- session : Optional [requests .Session ] = None ,
7071 per_page : Optional [int ] = None ,
7172 pagination : Optional [str ] = None ,
7273 order_by : Optional [str ] = None ,
7374 user_agent : str = gitlab .const .USER_AGENT ,
7475 retry_transient_errors : bool = False ,
7576 keep_base_url : bool = False ,
77+ ** kwargs : Any ,
7678 ) -> None :
79+ """
80+ kwargs:-
81+ :param requests.Session session: (optional). Http Requests Session.
82+ :param RequestsEngine http_engine: (optional). Engine that will be used
83+ to make http requests.
84+ """
7785
7886 self ._api_version = str (api_version )
7987 self ._server_version : Optional [str ] = None
@@ -98,7 +106,9 @@ def __init__(
98106 self ._set_auth_info ()
99107
100108 #: Create a session object for requests
101- self .session = session or requests .Session ()
109+ http_engine = kwargs .pop ("http_engine" , http_engines .DefaultEngine )
110+ self .http_engine = http_engine (** kwargs )
111+ self .session = self .http_engine .client
102112
103113 self .per_page = per_page
104114 self .pagination = pagination
0 commit comments