Haproxy 正在终止 https 连接并将请求转发到后端。当资源返回 204 No-Content 和 Transfer-Encoding: chunked 时,curl 连接未关闭。当我直接在后端调用资源时,连接已正确关闭。有人能解释一下这种行为吗?这是 haproxy 或 curl 特有的现象,还是预料之中的?
通过 haproxy:
curl -X GET https://localhost/example -v
* About to connect() to localhost port 443 (#0)
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 443 (#0)
> GET /example HTTP/1.1
> User-Agent: curl/7.29.0
> Host: localhost
> Accept: */*
>
< HTTP/1.1 204 No Content
< Cache-Control: no-cache, no-store, must-revalidate
< Date: Wed, 23 Aug 2017 13:15:16 GMT
< transfer-encoding: chunked
<
^C
直接后端:
curl -X GET http://localhost:6083/example -v
* About to connect() to localhost port 6083 (#0)
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 6083 (#0)
> GET /example HTTP/1.1
> User-Agent: curl/7.29.0
> Host: localhost:6083
> Accept: */*
>
< HTTP/1.1 204 No Content
< Cache-Control: no-cache, no-store, must-revalidate
< Date: Wed, 23 Aug 2017 14:19:03 GMT
< transfer-encoding: chunked
<
* Connection #0 to host localhost left intact