request/response的header可以含有回车么? - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
httpbin - 协议调试工具
httpstatuses - 协议状态码查询
httpie - cURL-like tool for humans
Fiddler
pyKun
V2EX    HTTP

request/response的header可以含有回车么?

  •  
  •   pyKun 2013 年 6 月 8 日 5302 次点击
    这是一个创建于 4676 天前的主题,其中的信息可能已经有所发展或是发生改变。
    具体的是\n
    carriage return
    (没有\t)

    在curl的文档里有提到:
    curl will make sure that each header you add/replace is sent with the proper end-of-line marker, you should thus not add that as a part of the header content: do not add newlines or carriage returns, they will only mess things up for you.

    但是我想要到http协议的依据,这样是不行的
    例如这里
    http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2
    有http的协议说header line是不能包括回车,必须要quote的么?
    8 条回复    1970-01-01 08:00:00 +08:00
    elden
        1
    elden  
       2013 年 6 月 8 日
    header的字段值可以包含换行符,但后面必需跟有空格或tab,否则后面的字符就会被当做下一个字段来解析。
    pyKun
        2
    pyKun  
    OP
       2013 年 6 月 8 日
    pyKun
        3
    pyKun  
    OP
       2013 年 6 月 8 日
    @elden
    这个引用有链接么?
    tab是LF么?
    pyKun
        4
    pyKun  
    OP
       2013 年 6 月 8 日
    elden
        5
    elden  
       2013 年 6 月 8 日
    @pyKun tab是\t


    rfc2616 2.2 http://www.w3.org/Protocols/rfc2616/rfc2616.txt

    "HTTP/1.1 header field values can be folded onto multiple lines if the
    continuation line begins with a space or horizontal tab. All linear
    white space, including folding, has the same semantics as SP. A
    recipient MAY replace any linear white space with a single SP before
    interpreting the field value or forwarding the message downstream."
    elden
        6
    elden  
       2013 年 6 月 8 日
    @pyKun 我是指\r\n或\n后面加空格
    pyKun
        7
    pyKun  
    OP
       2013 年 6 月 8 日
    @elden
    貌似看懂点了,换行到下个文本间要加空格

    那参照django和curl,其实我的client拒绝掉包含换行的value其实也没有问题
    elden
        8
    elden  
       2013 年 6 月 9 日
    @pyKun django不清楚,但curl是遵循rfc2616规范的
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2864 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 42ms UTC 03:17 PVG 11:17 LAX 20:17 JFK 23:17
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86