Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setup_headers(deadline=None, headers=None,
request_url="/", method="POST", gateway=False):
new_headers = {}
if gateway:
new_headers = hs.encap_headers(headers)
new_headers.update({
constants.FN_INTENT: constants.INTENT_HTTP_REQUEST,
})
elif headers is not None:
for k, v in headers.items():
new_headers.update({k: v})
new_headers.update({
constants.FN_HTTP_REQUEST_URL: request_url,
constants.FN_HTTP_METHOD: method,
})
if deadline is None:
now = dt.datetime.now(dt.timezone.utc).astimezone()
now += dt.timedelta(0, float(constants.DEFAULT_DEADLINE))
deadline = now.isoformat()
def SetResponseHeaders(self, headers, status_code):
log.log("setting headers. gateway: {0}".format(self.__is_gateway()))
if self.__is_gateway():
headers = hs.encap_headers(headers, status=status_code)
for k, v in headers.items():
self.__response_headers[k.lower()] = v