企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] # HTTP Header Equals(未校验) HTTP报头等于断言,检查报头是否存在于请求或响应中,是否具有所需的值。 >[warning]本断言适用于接收HTTP消息的测试步骤和虚拟API。 ## 适用场景 你可以在ReadyAPI套件的不同应用程序中使用此断言。根据应用程序的不同,断言验证以下数据: | 应用 | 检查数据 | 更多信息 | | --- | --- | --- | | [SoapUI](https://support.smartbear.com/readyapi/docs/soapui/intro/about.html) | request 和 response Header | [SoapUI断言](https://support.smartbear.com/readyapi/docs/testing/assertions/soap.html) | | [Secure ](https://support.smartbear.com/readyapi/docs/secure/intro/about.html) | response Header | [Security 断言](https://support.smartbear.com/readyapi/docs/secure/assertions.html) | | [ServiceV](https://support.smartbear.com/readyapi/docs/servicev/intro/about.html) | response Header | [ServiceV断言](https://support.smartbear.com/readyapi/docs/servicev/validating/assertions.html) | ## 创建断言 1、在对话框的左边,选择 **Compliance, Status and Standards** 类别。 2、在对话框的右边,选择 **HTTP Header Equals** 。 3、点击 **Add** 。 **SoapUI** ![SoapUI:The assertions Panel](https://support.smartbear.com/readyapi/docs/_images/testing/assertions/reference/create-soap.png) **Secure** ![Secure:The assertions Panel](https://support.smartbear.com/readyapi/docs/_images/testing/assertions/reference/create-secure.png) **ServiceV** ![ServiceV:The assertions Panel](https://support.smartbear.com/readyapi/docs/_images/testing/assertions/reference/create-servicev.png) ## 设置断言 1.在 **Header** 字段中指定 header 名称。 ![ReadyAPI:Configuring the HTTP Header Exists assertion](https://support.smartbear.com/readyapi/docs/_images/testing/assertions/reference/compliance/header-equals.png) 2.在 **Value** 编辑框中指定预期的 header 值。 3.选择其他选项以缩小期望值: | 选项 | 描述 | | --- | --- | | **Ignore case**| 使搜索用例不区分大小写 | | **Regular Expression**| 将输入的值视为正则表达式。要了解有关正则表达式语法的更多信息,请参见[Oracle documentation](https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html)。 | ## 状态代码和Header的其他断言 你可以为HTTP状态代码和响应Header添加更多的断言: ● [无效HTTP状态码断言](https://support.smartbear.com/readyapi/docs/testing/assertions/reference/compliance/http-invalid.html) ● [有效HTTP状态码断言](https://support.smartbear.com/readyapi/docs/testing/assertions/reference/compliance/http-valid.html) ● [HTTP Header存在断言](https://support.smartbear.com/readyapi/docs/testing/assertions/reference/compliance/header-exists.html) **参考资料** [1、ReadyAPI Documentation / Testing APIs / Verifying Results / Assertion Reference / Compliance Assertions / HTTP Header Equals](https://support.smartbear.com/readyapi/docs/index.html) --- :-: --- 贡献者名单(排名不分先后) --- :-: **材料** :-: **编写** 苏娟 :-: **校验** :-: **支持**