how to retreive the value of a custom header into a WSF_REQUEST

31 Views Asked by At

I'm looking how to get a custom header value from a received WSF_REQUEST. I read the docs quickly and didn't find the answer.

'Authorization': 'Bearer my_long_token'
2

There are 2 best solutions below

1
On

My complete solution was

last_request: detachable WSF_REQUEST

find_it
    do
        if attached header_item ("HTTP_AUTHORIZATION") as l_bearer then
            do_something (l_bearer)
        end
    end

meta_variable, header_item (a_key: STRING): detachable STRING
    require
        attached last_request -- {WSF_REQUEST}
    do
        check
            attached last_request as l_last_request
        then
            across
                l_last_request.meta_variables as l_item_cursor
            until
                attached Result
            loop
                --logger.write_debug ("header_item->key:" + l_item_cursor.item.name + " val:" + l_item_cursor.item.value)
                if l_item_cursor.item.name.is_equal (a_key) then
                    Result := l_item_cursor.item.value
                end
            end
        end
    end
0
On

Use http_authorization from the WSF_REQUEST interface. (all the request header values are available using the CGI convention, mostly prefixing with HTTP_ , all in uppercase, and using _ as separator.