summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/XMLHttpRequest/resources/auth5/auth.py
blob: bc739f5eb597f831cd11a5776e8bcdfd248eec8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
def main(request, response):
    if request.auth.username == 'usr' and request.auth.password == 'secret':
        response.headers.set('Content-type', 'text/plain')
        content = ""
    else:
        response.status = 401
        response.headers.set('Status', '401 Authorization required')
        response.headers.set('WWW-Authenticate', 'Basic realm="test"')
        content = 'User name/password wrong or not given: '

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