【问题标题】:Content-Encoding response header not returned in karate GET call空手道 GET 调用中未返回 Content-Encoding 响应标头
【发布时间】:2021-12-19 04:39:28
【问题描述】:

实际上,我正在尝试将我的旧测试套件迁移到空手道框架。 而且我必须验证响应标头,因为在空手道 GET 调用中未返回“Content-Encoding”标头 - 我在结果中检查了它,我可以看到所有其他响应标头但看不到“Content-Encoding”并返回 null 以进行断言。

我在 chrome 浏览器中检查了相同的 GET 调用 - 开发人员控制台和 POSTMAN 在这两个工具中我可以获得“内容编码”但在空手道中没有。

请帮帮我。

【问题讨论】:

    标签: karate


    【解决方案1】:

    如果服务器返回Content-Encoding,您将看到它,否则您将看不到。

    要验证标头是否存在,很简单:

    And match responseHeaders contains { 'Content-Encoding': '#notpresent' }
    

    参考responseHeadershttps://github.com/intuit/karate#responseheaders

    【讨论】:

      【解决方案2】:

      不幸的是,它没有提供所有响应标头,因为某些响应标头(例如“Content-Encoding: gzip”)在解压内容后被底层 Apache http 库剥离。

      见: Having trouble getting content-encoding to show up in response header for get request

      【讨论】:

        猜你喜欢
        • 2018-08-02
        • 2020-02-11
        • 2011-02-16
        • 2020-07-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-01-09
        • 1970-01-01
        相关资源
        最近更新 更多