Skip to content

Commit 3710b56

Browse files
RPRXmmmray
authored andcommitted
SplitHTTP: Add noSSEHeader
#3603 (comment)
1 parent 59f6685 commit 3710b56

File tree

5 files changed

+46
-29
lines changed

5 files changed

+46
-29
lines changed

infra/conf/transport_internet.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ type SplitHTTPConfig struct {
232232
MaxConcurrentUploads Int32Range `json:"maxConcurrentUploads"`
233233
MaxUploadSize Int32Range `json:"maxUploadSize"`
234234
MinUploadIntervalMs Int32Range `json:"minUploadIntervalMs"`
235+
NoSSEHeader bool `json:"noSSEHeader"`
235236
}
236237

237238
// Build implements Buildable.
@@ -260,6 +261,7 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) {
260261
From: c.MinUploadIntervalMs.From,
261262
To: c.MinUploadIntervalMs.To,
262263
},
264+
NoSSEHeader: c.NoSSEHeader,
263265
}
264266
return config, nil
265267
}

transport/internet/config.pb.go

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

transport/internet/splithttp/config.pb.go

Lines changed: 29 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

transport/internet/splithttp/config.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ message Config {
1313
RandRangeConfig maxConcurrentUploads = 4;
1414
RandRangeConfig maxUploadSize = 5;
1515
RandRangeConfig minUploadIntervalMs = 6;
16+
bool noSSEHeader = 7;
1617
}
1718

1819
message RandRangeConfig {

transport/internet/splithttp/hub.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
)
2727

2828
type requestHandler struct {
29+
config *Config
2930
host string
3031
path string
3132
ln *Listener
@@ -182,8 +183,10 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req
182183

183184
// magic header instructs nginx + apache to not buffer response body
184185
writer.Header().Set("X-Accel-Buffering", "no")
185-
// magic header to make the HTTP middle box consider this as SSE to disable buffer
186-
writer.Header().Set("Content-Type", "text/event-stream")
186+
if !h.config.NoSSEHeader {
187+
// magic header to make the HTTP middle box consider this as SSE to disable buffer
188+
writer.Header().Set("Content-Type", "text/event-stream")
189+
}
187190

188191
writer.WriteHeader(http.StatusOK)
189192
// send a chunk immediately to enable CDN streaming.
@@ -267,6 +270,7 @@ func ListenSH(ctx context.Context, address net.Address, port net.Port, streamSet
267270
var err error
268271
var localAddr = gonet.TCPAddr{}
269272
handler := &requestHandler{
273+
config: shSettings,
270274
host: shSettings.Host,
271275
path: shSettings.GetNormalizedPath("", false),
272276
ln: l,

0 commit comments

Comments
 (0)