Skip to content
12 changes: 9 additions & 3 deletions api/connector/Connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,21 @@ func (impl PumpImpl) StartK8sStreamWithHeartBeat(w http.ResponseWriter, isReconn
if !ok {
http.Error(w, "unexpected server doesnt support streaming", http.StatusInternalServerError)
}
if err != nil {
http.Error(w, errors.Details(err), http.StatusInternalServerError)
}

w.Header().Set("Transfer-Encoding", "chunked")
w.Header().Set("Content-Type", "text/event-stream")
w.Header().Set("X-Accel-Buffering", "no")
w.Header().Set("X-Content-Type-Options", "nosniff")
w.Header().Set("Cache-Control", "no-cache, no-transform")

if err != nil {
err := impl.sendEvent(nil, []byte("CUSTOM_ERR_STREAM"), []byte(err.Error()), w)
if err != nil {
impl.logger.Errorw("error in writing data over sse", "err", err)
}
return
}

if isReconnect {
err := impl.sendEvent(nil, []byte("RECONNECT_STREAM"), []byte("RECONNECT_STREAM"), w)
if err != nil {
Expand Down
Loading