Add support for returning header

The caller might need to access header elements, such as 'typ' or
'cty', in order to properly validate and parse the payload.

A new function is added that returns the header in addition to the
payload.