空手道中的空手道框架符号编码

时间:2020-01-29 21:24:19

标签: karate

我有这个:

Background:
    * url 'http://localhost:15672/api/exchanges/%2F/my_exchange'

Scenario:
    Given path 'publish'

这里的问题是该网址被解析为:

http://localhost:15672/api/exchanges///my_exchange/publish

代替:

http://localhost:15672/api/exchanges/%2F/my_exchange/publish

谢谢

已编辑:

我会改善这个问题。

我在这里上传了一个非常简单的项目:https://github.com/italktothewind/karate-encoding

它有一个监听/bar/%2F/foo的窃听器

此功能有效:

Feature: Working example

    Scenario:
        Given url 'http://localhost:1081/bar/%2F/foo'
        When method get
        Then status 200

但是此功能不起作用(我在项目中放置了@ignore标志,以便可以成功构建它):

Feature: Non working example

Background:
    * url 'http://localhost:1081/bar/%2F'

Scenario:
    Given path 'foo'
    When get
    Then status 200

这两个功能之间的区别是使用urlpath

1 个答案:

答案 0 :(得分:2)

为我工作:

* url 'https://httpbin.org/anything/%2F/my_exchange'
* method get

在日志中:

1 > GET https://httpbin.org/anything/%2F/my_exchange
1 > Accept-Encoding: gzip,deflate
1 > Connection: Keep-Alive
1 > Host: httpbin.org
1 > User-Agent: Apache-HttpClient/4.5.11 (Java/1.8.0_231)

编辑:当您使用非常规URL时,空手道中的一般建议是仅使用url(不要使用path):https://stackoverflow.com/a/53638335/143475