Skip to content

Commit

Permalink
Merge pull request #30 from SAP/us/CXCDC-28535-remove-hostCheck
Browse files Browse the repository at this point in the history
CXCDC-28535 remove host check
  • Loading branch information
shemma3 authored Feb 4, 2025
2 parents 112f060 + b9bbc4b commit 4cdbbea
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions GSSDK.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class GSRequest():
_useHTTPS = False
_apiDomain = DEFAULT_API_DOMAIN

def __init__(self, apiKey=None, secretKey=None, apiMethod=None, params=None, useHTTPS=False, userKey=None, enable_host_check=True):
def __init__(self, apiKey=None, secretKey=None, apiMethod=None, params=None, useHTTPS=False, userKey=None):
"""
Constructs a request using the apiKey and secretKey.
@param apiKey
Expand All @@ -95,7 +95,6 @@ def __init__(self, apiKey=None, secretKey=None, apiMethod=None, params=None, use
@param params the request parameters
@param useHTTPS useHTTPS set this to true if you want to use HTTPS.
@param userKey A key of an admin user with extra permissions.
@param enable_host_check Hostcheck can be disabled by passing enable_host_check=false when using HTTPS. Can be necessary when using proxy. Default is True
If this parameter is provided, then the secretKey parameter is assumed to be the admin user's secret key and not the site's secret key.
"""

Expand All @@ -119,7 +118,6 @@ def __init__(self, apiKey=None, secretKey=None, apiMethod=None, params=None, use
self._secretKey = secretKey
self._userKey = userKey
self._traceLog = list()
self._enableHostCheck = enable_host_check
self.traceField("apiMethod", apiMethod)
self.traceField("apiKey", apiKey)

Expand Down Expand Up @@ -175,7 +173,7 @@ def send(self, timeout=None):
self.traceField("params", self._params)
self.traceField("useHTTPS", self._useHTTPS)
self.traceField("userKey", self._userKey)
responseStr = self.sendRequest("POST", self._host, self._path, self._params, self._apiKey, self._secretKey, self._useHTTPS, timeout, self._userKey, self._enableHostCheck)
responseStr = self.sendRequest("POST", self._host, self._path, self._params, self._apiKey, self._secretKey, self._useHTTPS, timeout, self._userKey)

return GSResponse(self._method, responseStr, None, 0, None, self._traceLog)

Expand All @@ -190,7 +188,7 @@ def send(self, timeout=None):

return GSResponse(self._method, None, self._params, errCode, errMsg, self._traceLog)

def sendRequest(self, httpMethod, domain, path, params, token, secret=None, useHTTPS=False, timeout=None, userKey=None, enable_host_check=True):
def sendRequest(self, httpMethod, domain, path, params, token, secret=None, useHTTPS=False, timeout=None, userKey=None):

params["sdk"] = "python_" + self.VERSION
# prepare query params
Expand Down Expand Up @@ -218,12 +216,12 @@ def sendRequest(self, httpMethod, domain, path, params, token, secret=None, useH
params["oauth_token"] = token

# get rest response.
res = self.curl(resourceURI, params, timeout, enable_host_check)
res = self.curl(resourceURI, params, timeout)

return res


def curl(self, url, params=None, timeout=None, enable_host_check=True):
def curl(self, url, params=None, timeout=None):

queryString = self.buildQS(params)

Expand All @@ -235,12 +233,12 @@ def curl(self, url, params=None, timeout=None, enable_host_check=True):
if self._proxy:
opener = build_opener(
HTTPHandler(),
ValidHTTPSHandler(enable_host_check), # maybe always send False???
ValidHTTPSHandler(False),
ProxyHandler({proto: self._proxy}))
else:
opener = build_opener(
HTTPHandler(),
ValidHTTPSHandler(enable_host_check))
ValidHTTPSHandler())

queryString = queryString.encode('utf-8')

Expand Down

0 comments on commit 4cdbbea

Please sign in to comment.