Skip to content

Commit

Permalink
[MINOR]: Explicitly use session to support api that requires cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
amadolid committed Aug 22, 2024
1 parent e2dbf05 commit 8ede20f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions jaseci_core/jaseci/extens/act_lib/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def get(url: str, data: dict = {}, header: dict = {}):
Return - response object
"""
res = requests.get(url, json=data, headers=header)
res = requests.Session().get(url, json=data, headers=header)
ret = {"status_code": res.status_code}
try:
ret["response"] = res.json()
Expand All @@ -33,7 +33,7 @@ def post(url: str, data: dict = {}, header: dict = {}):
Return - response object
"""
res = requests.post(url, json=data, headers=header)
res = requests.Session().post(url, json=data, headers=header)
ret = {"status_code": res.status_code}
try:
ret["response"] = res.json()
Expand All @@ -52,7 +52,7 @@ def put(url: str, data: dict = {}, header: dict = {}):
Return - response object
"""
res = requests.put(url, json=data, headers=header)
res = requests.Session().put(url, json=data, headers=header)
ret = {"status_code": res.status_code}
try:
ret["response"] = res.json()
Expand All @@ -71,7 +71,7 @@ def delete(url: str, data: dict = {}, header: dict = {}):
Return - response object
"""
res = requests.delete(url, json=data, headers=header)
res = requests.Session().delete(url, json=data, headers=header)
ret = {"status_code": res.status_code}
try:
ret["response"] = res.json()
Expand All @@ -90,7 +90,7 @@ def head(url: str, data: dict = {}, header: dict = {}):
Return - response object
"""
res = requests.head(url, json=data, headers=header)
res = requests.Session().head(url, json=data, headers=header)
ret = {"status_code": res.status_code}
try:
ret["response"] = res.json()
Expand All @@ -109,7 +109,7 @@ def options(url: str, data: dict = {}, header: dict = {}):
Return - response object
"""
res = requests.options(url, json=data, headers=header)
res = requests.Session().options(url, json=data, headers=header)
ret = {"status_code": res.status_code}
try:
ret["response"] = res.json()
Expand Down Expand Up @@ -157,7 +157,7 @@ def multipart(
)
)

res = requests.post(url, data=data, files=_files, headers=header)
res = requests.Session().post(url, data=data, files=_files, headers=header)
ret = {"status_code": res.status_code}
try:
ret["response"] = res.json()
Expand Down Expand Up @@ -208,7 +208,7 @@ def trigger(
)
)

act = getattr(requests, method)
act = getattr(requests.Session(), method)

if data is not None:
kwargs["data"] = data
Expand Down

0 comments on commit 8ede20f

Please sign in to comment.