Pipo
Pipo

Reputation: 5083

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

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'

Upvotes: 2

Views: 30

Answers (2)

Pipo
Pipo

Reputation: 5083

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

Upvotes: 1

Jocelyn
Jocelyn

Reputation: 703

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.

Upvotes: 2

Related Questions