Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit283e7cc

Browse files
author
Liora Milbaum
authored
refactor: move the request call to the backend (#2413)
1 parent63cf4e4 commit283e7cc

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

‎gitlab/client.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ def http_request(
752752
cur_retries=0
753753
whileTrue:
754754
try:
755-
result=self.session.request(
755+
result=self.http_backend.http_request(
756756
method=verb,
757757
url=url,
758758
json=json,

‎gitlab/http_backends/requests_backend.py‎

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
fromtypingimportOptional
1+
fromtypingimportAny,Dict,Optional,Union
22

33
importrequests
4+
fromrequests_toolbelt.multipart.encoderimportMultipartEncoder# type: ignore
45

56

67
classRequestsBackend:
@@ -10,3 +11,43 @@ def __init__(self, session: Optional[requests.Session] = None) -> None:
1011
@property
1112
defclient(self)->requests.Session:
1213
returnself._client
14+
15+
defhttp_request(
16+
self,
17+
method:str,
18+
url:str,
19+
json:Optional[Union[Dict[str,Any],bytes]]=None,
20+
data:Optional[Union[Dict[str,Any],MultipartEncoder]]=None,
21+
params:Optional[Any]=None,
22+
timeout:Optional[float]=None,
23+
verify:Optional[Union[bool,str]]=True,
24+
stream:Optional[bool]=False,
25+
**kwargs:Any
26+
)->requests.Response:
27+
"""Make HTTP request
28+
29+
Args:
30+
method: The HTTP method to call ('get', 'post', 'put', 'delete', etc.)
31+
url: The full URL
32+
data: The data to send to the server in the body of the request
33+
json: Data to send in the body in json by default
34+
timeout: The timeout, in seconds, for the request
35+
verify: Whether SSL certificates should be validated. If
36+
the value is a string, it is the path to a CA file used for
37+
certificate validation.
38+
stream: Whether the data should be streamed
39+
40+
Returns:
41+
A requests Response object.
42+
"""
43+
returnself._client.request(
44+
method=method,
45+
url=url,
46+
params=params,
47+
data=data,
48+
timeout=timeout,
49+
stream=stream,
50+
verify=verify,
51+
json=json,
52+
**kwargs
53+
)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp