summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/compat
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-10-14 13:07:11 -0400
committerGitHub <noreply@github.com>2020-10-14 13:07:11 -0400
commite3eb6fd0e4115162e10caf6ae2196fd8774657e0 (patch)
tree9c75804b98eefa34a2cc924c8ccb2b8fc9c40d01 /pkg/api/handlers/compat
parentd30b4b7aa5076c3192faada7d408f039a40414eb (diff)
parenteb4a746efcb9e76e29942461b97da797fd67109f (diff)
downloadpodman-e3eb6fd0e4115162e10caf6ae2196fd8774657e0.tar.gz
podman-e3eb6fd0e4115162e10caf6ae2196fd8774657e0.tar.bz2
podman-e3eb6fd0e4115162e10caf6ae2196fd8774657e0.zip
Merge pull request #7987 from jwhonce/jira/run-898-5
Restore --format table support
Diffstat (limited to 'pkg/api/handlers/compat')
-rw-r--r--pkg/api/handlers/compat/events.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/pkg/api/handlers/compat/events.go b/pkg/api/handlers/compat/events.go
index a729b84d4..f74491a8f 100644
--- a/pkg/api/handlers/compat/events.go
+++ b/pkg/api/handlers/compat/events.go
@@ -112,11 +112,15 @@ func GetEvents(w http.ResponseWriter, r *http.Request) {
errorChannel <- runtime.Events(r.Context(), readOpts)
}()
- w.Header().Set("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
+ var flush = func() {}
if flusher, ok := w.(http.Flusher); ok {
- flusher.Flush()
+ flush = flusher.Flush
}
+
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+ flush()
+
coder := json.NewEncoder(w)
coder.SetEscapeHTML(true)
@@ -124,6 +128,7 @@ func GetEvents(w http.ResponseWriter, r *http.Request) {
select {
case err := <-errorChannel:
if err != nil {
+ // FIXME StatusOK already sent above cannot send 500 here
utils.InternalServerError(w, err)
return
}
@@ -136,9 +141,7 @@ func GetEvents(w http.ResponseWriter, r *http.Request) {
if err := coder.Encode(e); err != nil {
logrus.Errorf("unable to write json: %q", err)
}
- if flusher, ok := w.(http.Flusher); ok {
- flusher.Flush()
- }
+ flush()
case <-r.Context().Done():
return
}