在空手道DSL中,有没有办法让重定向执行POST请求而不是GET请求



我有以下空手道脚本,默认情况下打开了重定向。

  Scenario: First Test
    Given path 'somePath'
    And request ''
    And header Content-Type = 'text/html'
    And param _csrf = csrf
    And param username = 'username'
    And param password = 'password'
    When method post
    Then status 200

问题是从 API 获取 302 后,下一个请求会自动提交 GET 请求。我希望它提交一个 POST 请求。

在 cURL 中,有一个允许用户执行此操作的现有参数。 见下文。

-

-post302 遵循 302 后不要切换到 GET

在空手道DSL中有什么办法吗?

是的,请阅读configure folowRedirects的文档。还有一个关于如何读取 Location 响应标头以手动发出所需请求的示例。

Scenario: get redirects can be disabled
* configure followRedirects = false
Given path 'redirect'
When method get
Then status 302
And match header Location == demoBaseUrl + '/search'
* def location = responseHeaders['Location'][0]
Given url location

最新更新