http-console是一个用nodejs写的类似于CURL的第三方库文件. 
 可以很直观的发送http请求以及查看返回结果. 安装需求:
 1, 安装nodejs
 2, 安装npm
 3, npm install http-console
 我做了个简单的例子: 
 启动: http-console 127.0.0.1:3000 
 1, HTTP GET: 
http://127.0.0.1:3000/> GET /home
HTTP/1.1 200 OK
Etag: "5c7fa0cae55818cafc847a65e4bcb794"
Connection: close
Content-Type: application/json; charset=utf-8
Date: Mon, 17 Jan 2011 01:33:40 GMT
Server: WEBrick/1.3.1 (Ruby/1.8.7/2010-01-10)
X-Runtime: 13
Content-Length: 36
Cache-Control: private, max-age=0, must-revalidate
{ status: 'OK'}
2, HTTP POST:
http://127.0.0.1:3000/> POST /login
... username=weekface&password=1234
HTTP/1.1 200 OK
Etag: "5c7fa0cae55818cafc847a65e4bcb794"
Connection: close
Content-Type: application/json; charset=utf-8
Date: Mon, 17 Jan 2011 01:33:40 GMT
Server: WEBrick/1.3.1 (Ruby/1.8.7/2010-01-10)
X-Runtime: 13
Content-Length: 36
Cache-Control: private, max-age=0, must-revalidate
{ status: 'OK', username: "weekface"}
3, 还可以轻松的设置Headers, 保存cookies, 使用SSL等等. 比如如果我这样启动http-console: http-console 127.0.0.1:3000 --cookies 这样就会保存服务器端设置的cookies
http://127.0.0.1:3000/> \cookies
{
_rails_session: {
value: 'BAh7BzoQX2NzcmZfdG9rZW4iMWkvL0p1ZXAwUXVmWDNqdWJFVVNzT0k1akVwVEV1UDVWai9VZHFoekNSczA9Og9zZXNzaW9uX2lkIiVmMmU0N2M4NjMxZGZhNTQ0NGY2OTlhNmUwYzI2YjA1Nw==--70afef3fcc39b5109f1474d0c9a7935d8affc29c',
options: { path: '/', HttpOnly: undefined }
}
}
总而言之,http-console提供了CURL之外的另外一个不错的选择.也充分体现了nodejs的灵活与强大.
转载于:https://blog.51cto.com/writerok/710861