mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
feat(stream watchers) disable double chunking
This commit is contained in:
parent
629a827ee2
commit
5b924dfd4e
@ -4,7 +4,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
@ -74,11 +73,9 @@ func handleWatch(key string, recursive, stream bool, waitIndex string, w http.Re
|
||||
// watcher hub will not help to remove stream watcher
|
||||
// so we need to remove here
|
||||
defer watcher.Remove()
|
||||
chunkWriter := httputil.NewChunkedWriter(w)
|
||||
for {
|
||||
select {
|
||||
case <-closeChan:
|
||||
chunkWriter.Close()
|
||||
return nil
|
||||
case event, ok := <-watcher.EventChan:
|
||||
if !ok {
|
||||
@ -89,7 +86,7 @@ func handleWatch(key string, recursive, stream bool, waitIndex string, w http.Re
|
||||
}
|
||||
|
||||
b, _ := json.Marshal(event)
|
||||
_, err := chunkWriter.Write(b)
|
||||
_, err := w.Write(b)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user