Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
726 views
in Technique[技术] by (71.8m points)

Karate framework symbol encoding in url

I have this:

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

Scenario:
    Given path 'publish'

Problem here is that the url is being resolved as:

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

instead of:

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

Thanks

EDITED:

I will improve the question.

I uploaded a very simple project here: https://github.com/italktothewind/karate-encoding

It has a wiremock listening to /bar/%2F/foo

This feature is working:

Feature: Working example

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

But this feature is not working (I put an @ignore flag in the project so it can be built successfully):

Feature: Non working example

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

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

The difference between the two features is the use of url and path.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Works for me:

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

And in the log:

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)

EDIT: when you have un-conventional URL-s the general recommendation in Karate is to use only the url (don't use path): https://stackoverflow.com/a/53638335/143475


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...