2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-10-06 17:46:55 +00:00

fix(provtest): a fetch is ok only when curl finished it

_decode in provtest_lib/httpc.py builds the reply's "ok" field from the HTTP
status alone. curl writes the status as soon as the response header arrives,
so a connection closed in the middle of the body, or a transfer killed by
--max-time, still produces status 200. The http.conf scenario that fetches the
kernel and initrd "byte for byte" then reads a partial file as served.

The reply already carries the reason curl gave. "ok" now also requires that
reason to be absent.

xCAT-test/provtest/tests/test_parsers.py asserts it for a body cut short
(curl exit 18) and for a timeout while reading the body.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
Daniel Hilst
2026-09-12 09:20:13 -03:00
parent 5212a75179
commit 9adbb6ae67
+5 -1
View File
@@ -106,7 +106,11 @@ def _decode(done, url, body_file, header_file):
"header": _headers(header_file),
"content_type": content_type,
"error": error,
"ok": bool(status and 200 <= status < 400),
# curl prints the status as soon as the response header arrives. A
# transfer that then stopped -- the connection closed mid-body, the
# clock ran out -- leaves a status of 200 and a file holding part of a
# kernel, so the status alone does not say the fetch worked.
"ok": bool(status and 200 <= status < 400 and not error),
}
return Reply(kind="http", fields=fields, ok=fields["ok"], error=error,
sent=done.command(), raw=body)