decodePayload(payload, headers) {
        const contentType = headers[':content-type'];

        if (!contentType) {
            return payload;
        }

        if (contentType === 'application/json') {
            return JSON.parse(new TextDecoder().decode(payload));
        }

        if (contentType.startsWith('text/')) {
            return new TextDecoder().decode(payload);
        }

        return payload;
    }
Decode payload based on content-type header