V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
thomaswang
V2EX  ›  问与答

http 响应报文

  •  
  •   thomaswang · 2018-03-14 17:13:27 +08:00 · 1489 次点击
    这是一个创建于 2228 天前的主题,其中的信息可能已经有所发展或是发生改变。
    char response[] = "HTTP/1.1 200 OK\r\nKeep-Alive: 2\r\nContent-Length:14\r\nContent-Type: text/html\r\n\r\n<h1>nihao</h1>";
    write(*connect_sock, response, sizeof(response));
    

    我在写服务端软件,响应 http 请求,我构建一个简单的 http 响应报文,chrome 可以查看,postman 不能显示,我还需要添加点什么才能让 postman 显示呢

    QQ20180314-171122.png

    QQ20180314-171155.png

    9 条回复    2018-03-16 19:51:47 +08:00
    carlclone
        1
    carlclone  
       2018-03-14 17:18:47 +08:00
    http:// ?
    b821025551b
        2
    b821025551b  
       2018-03-14 17:35:15 +08:00
    这个是插件版的 postman 还是 app 版的?是不是走代理了
    chairuosen
        3
    chairuosen  
       2018-03-14 17:49:02 +08:00
    用 curl --verbose 试
    thomaswang
        4
    thomaswang  
    OP
       2018-03-14 18:09:17 +08:00
    @carlclone 对的
    thomaswang
        5
    thomaswang  
    OP
       2018-03-14 18:09:54 +08:00
    @b821025551b 没有,这个应该是我的响应报文缺少信息,postman 认为是一个不合法的响应
    thomaswang
        6
    thomaswang  
    OP
       2018-03-14 18:10:33 +08:00
    @chairuosen 想用 postman,图个方便
    chairuosen
        7
    chairuosen  
       2018-03-14 18:39:38 +08:00
    @thomaswang postman 不是没法显示么,你用 curl 对比你的和正常的结果有什么不同
    sunjourney
        8
    sunjourney  
       2018-03-14 20:23:36 +08:00
    http 协议最重要的 method 呢? 这个 keep-alive 用的太生僻了吧,一般是 Connection: Keep-Alive
    katsusan
        9
    katsusan  
       2018-03-16 19:51:47 +08:00 via iPhone
    看你 postman 里 body 是灰的,是不是 headers 和 body 的解析有问题
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2796 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 12:00 · PVG 20:00 · LAX 05:00 · JFK 08:00
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.