0
mirror of https://github.com/XTLS/Xray-core.git synced 2025-06-14 20:39:36 +03:00

SplitHTTP server: add ok padding (#3614)

This commit is contained in:
mmmray
2024-08-02 03:16:19 +02:00
committed by GitHub
parent 4c82ef8a1b
commit 4b7947cca9
5 changed files with 80 additions and 43 deletions

View File

@ -124,6 +124,7 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req
currentSession := h.upsertSession(sessionId)
scMaxEachPostBytes := int(h.ln.config.GetNormalizedScMaxEachPostBytes().To)
responseOkPadding := h.ln.config.GetNormalizedResponseOkPadding()
if request.Method == "POST" {
seq := ""
@ -192,6 +193,10 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req
// send a chunk immediately to enable CDN streaming.
// many CDN buffer the response headers until the origin starts sending
// the body, with no way to turn it off.
padding := int(responseOkPadding.roll())
for i := 0; i < padding; i++ {
writer.Write([]byte("o"))
}
writer.Write([]byte("ok"))
responseFlusher.Flush()