1

I am trying to write a test which validates my server rejects requests larger than 1MB:

Scenario: large requests are rejected
    Given url 'https://my.server.com/anything'
    And request "x".repeat(1048577)
    When method post
    Then status 413

This test fails with an javax.net.ssl.SSLException: Broken pipe (Write failed) exception because the server reads the Content-Length header and immediately rejects the request / responds with a 413 before reading the payload.

I verified the server behavior via cURL:

$> printf 'x%.0s' {1..1048577} | curl -i --data @- https://my.server.com/anything
HTTP/1.1 413 Request Entity Too Large

Is it possible to test this feature using Karate?

jckdnk111
  • 2,280
  • 5
  • 33
  • 43

1 Answers1

1

It certainly can be a case which Karate is not designed for. You may not have full control over some "special" headers like the Content-Length - and we are limited by the underlying Apache HTTP client.

I'm not sure if the upcoming 1.0 series will support this and allow you to over-write the Content-Length header: https://github.com/intuit/karate/wiki/1.0-upgrade-guide

But you are welcome to investigate and submit a PR if needed.

As a workaround, you can use cURL from Karate: https://stackoverflow.com/a/64352676/143475

And also see this answer: https://stackoverflow.com/a/73230200/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248