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,11 @@ class Gitlab:
5555 differs from response headers
5656 """
5757
58+ # The session object is defined here as long as the RequestsEngine is not
59+ # fully implemented. The long-term goal is to wrap all the http
60+ # requests/responses by the RequestsEngine class
61+ session : requests .Session
62+
5863 def __init__ (
5964 self ,
6065 url : Optional [str ] = None ,
@@ -66,14 +71,20 @@ def __init__(
6671 http_password : Optional [str ] = None ,
6772 timeout : Optional [float ] = None ,
6873 api_version : str = "4" ,
69- session : Optional [requests .Session ] = None ,
7074 per_page : Optional [int ] = None ,
7175 pagination : Optional [str ] = None ,
7276 order_by : Optional [str ] = None ,
7377 user_agent : str = gitlab .const .USER_AGENT ,
7478 retry_transient_errors : bool = False ,
7579 keep_base_url : bool = False ,
80+ ** kwargs : Any ,
7681 ) -> None :
82+ """
83+ kwargs:-
84+ :param requests.Session session: (optional). Http Requests Session.
85+ :param RequestsEngine http_engine: (optional). Engine that will be used
86+ to make http requests.
87+ """
7788
7889 self ._api_version = str (api_version )
7990 self ._server_version : Optional [str ] = None
@@ -98,7 +109,9 @@ def __init__(
98109 self ._set_auth_info ()
99110
100111 #: Create a session object for requests
101- self .session = session or requests .Session ()
112+ http_engine = kwargs .pop ("http_engine" , http_engines .DefaultEngine )
113+ self .http_engine = http_engine (** kwargs )
114+ self .session = self .http_engine .client
102115
103116 self .per_page = per_page
104117 self .pagination = pagination
0 commit comments