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')
  }
)