MCPcopy Index your code
hub / github.com/Tencent/CodeAnalysis / request

Method request

client/util/api/httpclient.py:26–49  ·  view source on GitHub ↗

:param url: :param headers: :param param: :param body: :param method: :return:

(url, headers, param=None, body=None, method="POST")

Source from the content-addressed store, hash-verified

24class HttpRequest(object):
25 @staticmethod
26 def request(url, headers, param=None, body=None, method="POST"):
27 """
28
29 :param url:
30 :param headers:
31 :param param:
32 :param body:
33 :param method:
34 :return:
35 """
36 if param:
37 url += "?" + param
38 if body and isinstance(body, str):
39 body = body.encode("utf-8")
40
41 try:
42 request = Request(url=url, data=body, headers=headers)
43 request.get_method = lambda: method.upper()
44 response = urlopen(request, context=ssl._create_unverified_context())
45 return response
46 except HTTPError as err:
47 error_msg = err.read().decode('utf-8')
48 logger.error(f"api request error: {error_msg}\nurl: {url}")
49 raise
50
51
52class HttpClient(object):

Callers 15

create_repositoryMethod · 0.80
create_projectMethod · 0.80
create_scansMethod · 0.80
get_scan_consMethod · 0.80
get_overviewMethod · 0.80
get_issuesMethod · 0.80
get_issue_detailMethod · 0.80
get_ccissuesMethod · 0.80
get_dupfilesMethod · 0.80
getMethod · 0.80
postMethod · 0.80

Calls 2

errorMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected