Created
March 31, 2013 09:35
-
-
Save vitallium/5280125 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var page = require('webpage').create(); | |
| var server = require('webserver').create(); | |
| server.listen(12345, function(request, response) { | |
| if (request.headers['Authorization']) { | |
| var encAuth = request.headers['Authorization'].substring(6); | |
| var credentials = atob(encAuth); | |
| response.statusCode = 200 | |
| response.write('Provided credentials:' + credentials); | |
| console.log(credentials); | |
| } else { | |
| response.statusCode = 401; | |
| response.setHeader('WWW-Authenticate', 'Basic realm="Basic Auth test"'); | |
| response.write('Authentication Required'); | |
| response.close(); | |
| } | |
| }); | |
| page.settings.userName = 'test'; | |
| page.settings.password = 'pwd'; | |
| page.open('http://localhost:12345', function(status) { | |
| if (status === 'success') { | |
| phantom.exit(); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment