Open b3b opened 2 years ago
Why Tempesta should close the connection? There is no Connection
header in the curl
request - does RFC requires to close connection by default?
If connection is not closed, then chunked body is expected by a client, but body is cutted off by Tempesta.
And even if Connection: close
is set by a client, header is replaced with Connection: keep-alive
by Tempesta.
+Content-Length
header has broken value instead of 0
.
Session with the Connection: close
set by a client:
# curl --verbose --max-time 16 172.17.0.1 -X PURGE -H 'X-Tempesta-Cache: get' -H 'Connection: close'
* Trying 172.17.0.1:80...
* Connected to 172.17.0.1 (172.17.0.1) port 80 (#0)
> PURGE / HTTP/1.1
> Host: 172.17.0.1
> User-Agent: curl/7.83.1
> Accept: */*
> X-Tempesta-Cache: get
> Connection: close
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Date: Fri, 16 Sep 2022 13:09:36 GMT
< X-Powered-By: PHP/7.4.30
< Link: <http://127.0.0.1/index.php?rest_route=/>; rel="https://api.w.org/"
< Vary: Accept-Encoding
< Connection: close
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=UTF-8
< Content-Length: 0via: 1.1 tempesta_fw (Tempesta FW pre-0.7.0)
< Server: Tempesta FW/pre-0.7.0
<
* transfer closed with outstanding read data remaining
* Closing connection 0
curl: (18) transfer closed with outstanding read data remaining
Test added to check that Connection: close
header is not passed to backend: cache.test_purge.TestPurgeGetWithTransferEncoding
It seems the problem is that the backend sends Transfer-Encoding: chunked
and when Tempesta FW cuts off the response for X-Tempesta-Cache: get
if doesn't cut off Transfer-Encoding
.
Scope
For PURGE requests with the
X-Tempesta-Cache: get
header set:Content-Length
value is concatenated with the next header:0via: 1.1 tempesta_fw (Tempesta FW pre-0.7.0)
WordPress https://github.com/tempesta-tech/tempesta-test/issues/290 home page purging example:
Raw response from WordPress:
Testing
Test to reproduce: cache.test_purge.TestPurgeGetWithTransferEncoding