if (typeof value === 'undefined' || value === null || typeof value.toString !== 'function') {
            throw new Error('Header ' + key + ' contains invalid value');
          }