1

I'm trying to use Karate to check the behavior of our server when paths contain multiple slashes, so I have a test like

  Scenario: Multiple slashes
    * url 'http://localhost'
    Given path '///some//path///'
    When method get
    Then status 404

When running this, the Karate output/log contains all the slashes:

12:04:52.307 [pool-1-thread-1]  DEBUG com.intuit.karate - request:
1 > GET http://localhost///some//path///
1 > Host: localhost

But according to the server log (simply using Apache for this demo), the actual request just has single slashes:

127.0.0.1 - - [23/Aug/2021:12:04:52 +0200] "GET /some/path/ HTTP/1.1" 404 488 "-" "Apache-HttpClient/4.5.13 (Java/11.0.4)"

So I have several questions:

  1. Is that slash normalization the expected (and documented?) behavior?
  2. Can I switch it off somewhere?
  3. If the slashes are collapsed, shouldn't the log contain the actual (normalized) request, so that I see what's really sent to the server?
DonHolgo
  • 123
  • 4
  • I believe this is Apache behaviour, so while Karate is sending the multiple slashes (and logging as such) Apache is stripping them and logging as such. Multiple slashes are against defined standards. – CT14.IT Aug 23 '21 at 10:30
  • @CT14.IT That's why we want to test the behavior. :-) But no, when I use `curl` instead of Karate and send `curl "http://localhost///some//path///"`, I do see all the slashes in the Apache log too. – DonHolgo Aug 23 '21 at 10:31
  • Ahh OK sorry wasn't aware of the differences! I might delete my comments then – CT14.IT Aug 23 '21 at 10:34

1 Answers1

0

You can see if this thread answers your question, combined with the path keyword (scroll to the end): https://github.com/intuit/karate/issues/1561

If not, you can assume this is not directly supported. Personally I don't think such use-cases are worth automating with Karate.

Work-arounds are to make your own HTTP call by integrating any Java lib (via Karate interop) or using cURL (hack): https://stackoverflow.com/a/64352676/143475

You are welcome to contribute code to Karate.

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • Thanks! I'm still trying to make my way through the Github issue, but since I'm not supposed to put too much time into the problem, I guess curl will be the way to go. – DonHolgo Aug 25 '21 at 19:28