Currently having an issue with response.headers, karate version 0.6.1 (has this been fixed in later versions?)
We have API tests which run against deployments on different platforms. Here is the test:
# Create Account
Given path 'pathToAccounts'
And headers { Authorization: '#(authToken)', Content-Type: "application/json"}
And request accountDetails
When method post
Then status 204
And match responseHeaders.Etag == '#notnull'
Here is the error which occurs when testing the windows deployment:
com.intuit.karate.exception.KarateException: No results for path: $['Etag']
at com.intuit.karate.StepDefs.matchNamed(StepDefs.java:554)
at com.intuit.karate.StepDefs.matchEquals(StepDefs.java:540)
at ✽.And match responseHeaders.Etag == '#notnull'(C:/......)
Here is the response from the windows deployment:

Here is the response from the linux deployment (on which the tests always pass):

So, it seems that the headers' names are treated case-sensitively by karate, when they should be case insensitive according to the HTTP spec.
Thanks!
I think you have a good point. treating this as a feature request. one option is we could convert all headers to lower-case before setting the responseHeaders variable. just worried existing tests may break.
alternatively, this need has come up a couple of times - a helper function to convert a given payload into lower-case (both the keys and values) may be useful to have out-of-the-box in karate.
thoughts from others welcome
just remembered we have a not-so-obvious match header short-cut for headers. it is documented here: https://github.com/intuit/karate#match-header
so I'm thinking all we need to do is ensure that match header will look for the key and ignore-case !
Thanks for the quick response, will make sure to check back for 0.9.0 :)
Is there anything you'd recommend for a temporary workaround?
If this is a problem that has just started manifesting, some reverse proxies and load balancers rewrite response headers. If you've made any changes to these, that may be causing the problem.
@mmwatt this hack should work :)
And assert responseHeaders.Etag || responseHeaders.etag
@mmwatt fixed in the cukexit branch.
introduced a new configure key called lowerCaseResponseHeaders here is an example: https://github.com/intuit/karate/blob/e0cc435b5de7a721b0b6a23c8ae6fcb15f69a9b9/karate-demo/src/test/java/demo/headers/content-type.feature
@mmwatt this hack should work :)
And assert responseHeaders.Etag || responseHeaders.etag
This workaround does not work for me, it just results in an error of the form:
com.jayway.jsonpath.PathNotFoundException: No results for path: $['Etag']
Just checking for a header that is not present seems to throw an exception of some sort.
@vnayar yes of course ! please try 0.9.0.RC4 and see the comment above yours please.
@vnayar yes of course ! please try 0.9.0.RC4 and see the comment above yours please.
Seems to be working well, thanks! I just had to make sure that the anticipated value in the feature file was also changed to lower case.
0.9.0 released