测试>时管道破裂(写入失败).允许的最大内容长度 [英] Broken pipe (Write failed) when testing > max allowed Content-Length
问题描述
我正在尝试编写一个测试来验证我的服务器是否拒绝了大于1MB的请求:
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
此测试失败,并出现 javax.net.ssl.SSLException:管道中断(写入失败)
异常,因为服务器读取了 Content-Length
标头并立即拒绝了在读取有效负载之前请求/响应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.
我通过cURL验证了服务器行为:
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?
推荐答案
这肯定是空手道不适合的情况.您可能无法完全控制某些特殊"商品.标头,例如 Content-Length
-,我们受到基础Apache HTTP客户端的限制.
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.
我不确定即将推出的1.0系列是否支持此功能,并允许您覆盖 Content-Length
标头: https://github.com/intuit/karate/wiki/1.0-upgrade-guide
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
但是欢迎您进行调查并在需要时提交PR.
But you are welcome to investigate and submit a PR if needed.
作为解决方法,您可以使用来自空手道的cURL: https://stackoverflow.com/a/64352676/143475
As a workaround, you can use cURL from Karate: https://stackoverflow.com/a/64352676/143475
这篇关于测试>时管道破裂(写入失败).允许的最大内容长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!