file-client-auth.js 299 Bytes
Newer Older
Caleb C. Sander's avatar
Caleb C. Sander committed
1
2
3
4
5
6
7
8
9
10
11
const http = require('http')

http.get(
  'http://localhost/index.html',
  {headers: {user: 'bob', password: 'supersecretpassword'}},
  res => {
    // If allowed to access the page, print it out
    if (res.statusCode === 200) res.pipe(process.stdout)
    else console.error('Invalid login')
  }
)