def render(self, request):
        """
        Send www-authenticate headers to the client
        """
        def ensureBytes(s):
            return s.encode('ascii') if isinstance(s, unicode) else s

        def generateWWWAuthenticate(scheme, challenge):
            l = []
            for k, v in challenge.items():
                k = ensureBytes(k)
                v = ensureBytes(v)
                l.append(k + b"=" + quoteString(v))
            return b" ".join([scheme, b", ".join(l)])

        def quoteString(s):
            return b'"' + s.replace(b'\\', b'\\\\').replace(b'"', b'\\"') + b'"'

        request.setResponseCode(401)
        for fact in self._credentialFactories:
            challenge = fact.getChallenge(request)
            request.responseHeaders.addRawHeader(
                b'www-authenticate',
                generateWWWAuthenticate(fact.scheme, challenge))
        if request.method == b'HEAD':
            return b''
        return b'Unauthorized'

        Send www-authenticate headers to the client
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/_auth/wrapper.py