V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
hujianxin
V2EX  ›  程序员

Content-Type: application/json; charset=utf-8,里面这个 charset 是协议规定的吗?

  •  
  •   hujianxin · 2019-02-15 12:36:35 +08:00 · 6359 次点击
    这是一个创建于 1896 天前的主题,其中的信息可能已经有所发展或是发生改变。

    在使用 java 的 http 框架发送 put 请求时,content type 设为 application/json,但是实际发送的是 application/json; charset=utf-8。

    请教各位大佬,这是一种规范吗?还是一种规定呢?

    4 条回复    2019-02-15 13:40:33 +08:00
    leoleoasd
        1
    leoleoasd  
       2019-02-15 12:50:42 +08:00
    rfc 里写的吧
    xj577
        2
    xj577  
       2019-02-15 13:07:26 +08:00
    感觉是一种兼容性需求而非硬性规定要求,搜了下关于 media type 和 application/json 的 rfc,并没有规定在 json 的 content-type 里设定 charset。
    RFC8259: No "charset" parameter is defined for this registration. Adding one really has no effect on compliant recipients.
    hujianxin
        3
    hujianxin  
    OP
       2019-02-15 13:37:00 +08:00
    @xj577 多谢
    hilbertz
        4
    hilbertz  
       2019-02-15 13:40:33 +08:00
    http 就是这么啰嗦的,实际没啥用处
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5418 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 07:30 · PVG 15:30 · LAX 00:30 · JFK 03:30
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.