summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/xhr/resources/auth6/auth.py
blob: e18319e3de8e03121f7d6a612c2da9549f0489a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from wptserve.utils import isomorphic_decode

def main(request, response):
    if request.auth.username == b'usr' and request.auth.password == b'secret':
        response.headers.set(b'Content-type', b'text/plain')
        content = b""
    else:
        response.status = 401
        response.headers.set(b'Status', b'401 Authorization required')
        response.headers.set(b'WWW-Authenticate', b'Basic realm="test"')
        content = b'User name/password wrong or not given: '

    content += b"%s\n%s" % (request.auth.username,
                            request.auth.password)
    return content