• 请不要在回答技术问题时复制粘贴 AI 生成的内容
Registering
V2EX  ›  程序员

感觉 Http 的各种头部有点混乱,怎么破

  •  
  •   Registering · Jun 16, 2015 · 3120 views
    This topic created in 3995 days ago, the information mentioned may be changed or developed.

    在封装一个http请求的小轮子,但是发现处理请求头部和响应头部时挺麻烦了,各个头部有点杂(大部分原因是自己不够熟练),搜了点资料,但是还是有点混乱。

    比如Http头部有一个叫Content-Type
    它可以设置成这样

    connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset="+ charset);
    

    想问问提交数据分别是字符串,文件,json等等时,该头部怎么设置。

    其实这个问题大概知道怎么处理了。更想请教大家的是:感觉http头部好杂好乱,怎么破,,,,

    5 replies    2015-06-16 22:14:51 +08:00
    Scholer
        1
    Scholer  
       Jun 16, 2015
    有本书叫《HTTP权威指南》
    Magic347
        2
    Magic347  
       Jun 16, 2015
    http://www.ietf.org/rfc/rfc2616.txt

    refer to 14-Header Field Definitions
    qgy18
        3
    qgy18  
       Jun 16, 2015 via iPhone
    Registering
        4
    Registering  
    OP
       Jun 16, 2015
    @qgy18
    看了,一边在查阅,,
    Registering
        5
    Registering  
    OP
       Jun 16, 2015
    @Scholer

    看了,一边在查阅,,
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1267 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 48ms · UTC 17:18 · PVG 01:18 · LAX 10:18 · JFK 13:18
    ♥ Do have faith in what you're doing.