Skip to content

Commit

Permalink
Merge pull request moby#16419 from HuKeping/comments
Browse files Browse the repository at this point in the history
Comment: add description for some code which hard to understand
  • Loading branch information
abronan committed Sep 22, 2015
2 parents 1088910 + 3b443ab commit f97e6f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion api/server/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,12 @@ func (s *Server) getEvents(ctx context.Context, w http.ResponseWriter, r *http.R
d := s.daemon
es := d.EventsService
w.Header().Set("Content-Type", "application/json")

outStream := ioutils.NewWriteFlusher(w)
outStream.Write(nil) // make sure response is sent immediately
// Write an empty chunk of data.
// This is to ensure that the HTTP status code is sent immediately,
// so that it will not block the receiver.
outStream.Write(nil)
enc := json.NewEncoder(outStream)

getContainerID := func(cn string) string {
Expand Down
3 changes: 3 additions & 0 deletions daemon/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ func (daemon *Daemon) ContainerStats(prefixOrName string, config *ContainerStats
}

if config.Stream {
// Write an empty chunk of data.
// This is to ensure that the HTTP status code is sent immediately,
// even if the container has not yet produced any data.
config.OutStream.Write(nil)
}

Expand Down

0 comments on commit f97e6f2

Please sign in to comment.