NickCirv/http-headers
GitHub: NickCirv/http-headers
一款零依赖的 HTTP 响应头检查 CLI 工具,提供安全评分、缓存审计、CORS 检查及多环境 header 对比功能。
Stars: 0 | Forks: 0
# http-headers
**检查 HTTP 响应头 — 安全评分、缓存审计、CORS 检查 — 一条命令搞定**
[](LICENSE)
[](package.json)
[](package.json)
## 安装
无需全局安装:
```
npx github:NickCirv/http-headers
```
或者全局安装:
```
npm install -g github:NickCirv/http-headers
```
## 用法
```
# 显示所有响应头
npx github:NickCirv/http-headers https://example.com
# 完整审计:security + caching + CORS
hheaders https://example.com --all
# 仅 security score (0–100)
hheaders https://api.example.com --security
# 用于脚本编写的 JSON 输出
hheaders https://example.com --all --format json
# 比较两个环境的 headers
hheaders https://staging.example.com --compare https://example.com
# 自定义 header(使用 env var 引用——切勿硬编码 secrets)
hheaders https://api.example.com --header "Authorization: $API_TOKEN"
```
| 参数 | 描述 |
|------|-------------|
| `--security` | HSTS、CSP、X-Frame-Options、X-Content-Type-Options、Referrer-Policy、Permissions-Policy、Server header — 评分范围 0–100 |
| `--caching` | Cache-Control、ETag、Expires、Vary、Age、CDN header(Cloudflare、CloudFront) |
| `--cors` | Access-Control-Allow-Origin、credentials、methods、headers、preflight max-age |
| `--all` | 同时执行全部三种审计 |
| `--follow` | 跟随重定向(默认:显示重定向链) |
| `--compare ` | 直观对比两个 URL 的 header 差异 |
| `--format json` | 输出机器可读的 JSON |
| `--method ` | HTTP method(默认:GET) |
| `--header "K: V"` | 发送自定义请求 header |
## 功能说明
`http-headers` 仅使用 Node.js 内置模块获取 URL 的响应头 —— 零依赖、无需 shell exec —— 并渲染带有颜色标记的表格。`--security` 参数按 0–100 的分制对六个常见的安全 header(HSTS、CSP、X-Frame-Options、X-Content-Type-Options、Referrer-Policy、Permissions-Policy)进行评分,并准确说明缺失了哪些内容。`--caching` 参数会提取 Cache-Control 策略、TTL、ETag 和 CDN 缓存信号。`--compare` 参数将两个 URL 的 header 并排进行差异对比,非常适合用于预发布环境与生产环境的对比检查。
零依赖 · Node ≥18 · MIT · 作者 NickCirv标签:CORS检查, GNU通用公共许可证, MITM代理, Node.js, SOC Prime, 开发工具, 文档结构分析, 缓存分析, 自定义脚本