src/drivers/webextension/js/driver.js
/**
   * Analyse response headers
   * @param {Object} request
   */
Analyse response headers
@param {Object} request
Analyse response headers @param { Object } request
async onHeadersReceived(request) {
    if (await Driver.isDisabledDomain(request.url)) {
      return
    }
    if (request.responseHeaders) {
      const headers = {}
      try {
        const [tab] = await promisify(chrome.tabs, 'query', {
          url: [request.url],
        })
        if (tab) {
          request.responseHeaders.forEach((header) => {
            const name = header.name.toLowerCase()
            headers[name] = headers[name] || []
            headers[name].push(
              (header.value || header.binaryValue || '').toString()
            )
          })
          let certIssuer = ''
          if (typeof browser !== 'undefined') {
            const { certificates } = await browser.webRequest.getSecurityInfo(
              request.requestId,
              {
                certificateChain: false,
                rawDER: false,
              }
            )
            if (certificates && certificates.length) {
              certIssuer = certificates[0].issuer.replace(
                /^.*CN=([^,]+).*$/,
                '$1'
              )
            }
          }
          if (
            headers['content-type'] &&
            /\/x?html/.test(headers['content-type'][0])
          ) {
            await Driver.onDetect(request.url, analyze({ headers, certIssuer }))
          }
        }
      } catch (error) {
        Driver.error(error)
      }
    }
  }
async onHeadersReceived ( request ) { if ( await Driver . isDisabledDomain ( request . url ) ) { return } if ( request . responseHeaders ) { const headers = { } try { const [ tab ] = await promisify ( chrome . tabs , 'query' , { url : [ request . url ] , } ) if ( tab ) { request . responseHeaders . forEach ( ( header ) => { const name = header . name . toLowerCase ( ) headers [ name ] = headers [ name ] || [ ] headers [ name ] . push ( ( header . value || header . binaryValue || '' ) . toString ( ) ) } ) let certIssuer = '' if ( typeof browser !== 'undefined' ) { const { certificates } = await browser . webRequest . getSecurityInfo ( request . requestId , { certificateChain : false , rawDER : false , } ) if ( certificates && certificates . length ) { certIssuer = certificates [ 0 ] . issuer . replace ( / ^.*CN=([^,]+).*$ / , '$1' ) } } if ( headers [ 'content-type' ] && / \/x?html / . test ( headers [ 'content-type' ] [ 0 ] ) ) { await Driver . onDetect ( request . url , analyze ( { headers , certIssuer } ) ) } } } catch ( error ) { Driver . error ( error ) } } }
Analyse response headers
 @param {Object} request
Analyse response headers @param { Object } request
// Currently only works in Firefox // See https://stackoverflow.com/a/50484642