From 12cdcbcecfe48d89a668ae460d35794d12def951 Mon Sep 17 00:00:00 2001 From: Nicholas Dudfield Date: Tue, 9 Jun 2026 15:12:39 +0700 Subject: [PATCH] fix: don't translate EOF to success in HTTPClient handleData Revert the eof->success translation from the previous commit. The upstream rippled #6344 deliberately keeps forwarding ecResult as-is; translating eof to success would report a truncated Content-Length response (server closes before sending the promised N body bytes) as a successful read and suppress HTTPClient::get() multi-site fallback. Keeps the structural simplification (collapsed branches, early return). --- src/xrpld/net/detail/HTTPClient.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/xrpld/net/detail/HTTPClient.cpp b/src/xrpld/net/detail/HTTPClient.cpp index 1820aad7b..523d0972f 100644 --- a/src/xrpld/net/detail/HTTPClient.cpp +++ b/src/xrpld/net/detail/HTTPClient.cpp @@ -448,18 +448,21 @@ public: return; } - // Either the read completed normally or it ended at EOF with no - // Content-Length. Both cases deliver the accumulated body. EOF - // is the expected end-of-message here, not an error, so report - // success — otherwise invokeComplete() forwards eof as an error - // code and the caller treats a complete response as a failure. + // Either the read completed normally or it ended at EOF (an + // EOF-delimited response with no Content-Length, or a truncated + // one). Deliver the accumulated body and forward ecResult as-is: + // success when the read completed, eof otherwise. We deliberately + // do NOT translate eof to success — a server that promises + // Content-Length: N and closes early must surface as an error, + // and HTTPClient::get() relies on a non-zero code to fall back to + // the next site. JLOG(j_.trace()) << "Complete."; mResponse.commit(bytes_transferred); std::string strBody{ {std::istreambuf_iterator(&mResponse)}, std::istreambuf_iterator()}; - invokeComplete(boost::system::error_code{}, mStatus, mBody + strBody); + invokeComplete(ecResult, mStatus, mBody + strBody); } // Call cancel the deadline timer and invoke the completion routine.