How to use the fdk.headers.encap_headers function in fdk

To help you get started, we’ve selected a few fdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fnproject / fdk-python / fdk / fixtures.py View on Github external
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()
github fnproject / fdk-python / fdk / context.py View on Github external
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