From 513182adf35345b89a41fe2d4fa529fd346c4779 Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Sun, 11 Aug 2024 01:56:25 +0200 Subject: [PATCH] SplitHTTP server: Only "ok" to older clients (#3671) https://github.com/XTLS/Xray-core/pull/3643#issuecomment-2282304185 --- transport/internet/splithttp/hub.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index 701c265e..88acbcd3 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -192,12 +192,15 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req h.config.WriteResponseHeader(writer) writer.WriteHeader(http.StatusOK) - // in earlier versions, this initial body data was used to immediately - // start a 200 OK on all CDN. but xray client since 1.8.16 does not - // actually require an immediate 200 OK, but now requires these - // additional bytes "ok". xray client 1.8.24+ doesn't require "ok" - // anymore, and so this line should be removed in later versions. - writer.Write([]byte("ok")) + if _, ok := request.URL.Query()["x_padding"]; !ok { + // in earlier versions, this initial body data was used to immediately + // start a 200 OK on all CDN. but xray client since 1.8.16 does not + // actually require an immediate 200 OK, but now requires these + // additional bytes "ok". xray client 1.8.24+ doesn't require "ok" + // anymore, and so this line should be removed in later versions. + writer.Write([]byte("ok")) + } + responseFlusher.Flush() downloadDone := done.New()