はじめて telnet を扱う人が雑に試してみた情報です。
BASIC認証を要求するWebサーバを立てる
$ echo '<h1>Hello</h1>' > index.html
$ npm i -g serve
$ export SERVE_USER=admin
$ export SERVE_PASSWORD=secret
$ serve -a
┌──────────────────────────────────────────────────┐
│ │
│ Serving! │
│ │
│ - Local: http://localhost:3000 │
│ - On Your Network: http://192.168.0.21:3000 │
│ │
│ Copied local address to clipboard! │
│ │
└──────────────────────────────────────────────────┘
telnet
コマンドを使う
BASIC認証が有効なことを確認する
$ telnet localhost 3000
Trying ::1...
Connected to localhost.
Escape character is '^]'.
GET / HTTP/1.1
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic realm="User Visible Realm"
Content-Length: 13
Date: Wed, 22 Feb 2017 15:04:20 GMT
Connection: keep-alive
Access Denied
認証情報を付加してお返事をいただく
$ telnet localhost 3000
Trying ::1...
Connected to localhost.
Escape character is '^]'.
GET / HTTP/1.1
Authorization: Basic YWRtaW46c2VjcmV0 ★ココ★
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Accept-Ranges: bytes
Cache-Control: public, max-age=3
Last-Modified: Wed, 22 Feb 2017 14:37:44 GMT
ETag: W/"f-15a6641aac0"
Content-Length: 15
Vary: Accept-Encoding
Date: Wed, 22 Feb 2017 15:04:55 GMT
Connection: keep-alive
<h1>Hello</h1>