How to let the json file (*.json) return response header: 'application/json', instead of 'application/json; charset=UTF-8'

未关闭
#859 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
javascript
领域
backend, cli

调研方向

使用提供的 http-server 命令重现响应,并检查确定 .json 文件 Content-Type 的源代码。确认当前的标头行为,并找出相关的响应标头处理逻辑。完成的标准是 JSON 文件在没有 charset 后缀的情况下准确返回 application/json,并通过针对性测试或等效请求验证该行为。

由索引模型根据 Issue 内容生成。

描述

stale
Environment Versions
  1. OS Type macOS
  2. Node version: $ node --version v12.22.12
  3. http-server version: $ http-server --version v14.1.1
Steps to reproduce

I have a json text file and start http-server

http-server ./public -c-1 -p 3000 --cors

What I got is: application/json; charset=UTF-8

How can I just let it return application/json?
I'm using latest http-server version, but I checked the source code, looks like this issue has been there from the very beginning.

Expected result

application/json

Actual result

application/json; charset=UTF-8

image

Thanks.

主要语言
JavaScript
星标
14.2k
派生
1.6k
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

http-party/http-server 的其他 Issue

查看 http-party/http-server 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。