mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Comment: add description for some code which hard to understand
Signed-off-by: Hu Keping <hukeping@huawei.com>
This commit is contained in:
parent
4a6e8c8f3c
commit
3b443abec2
2 changed files with 8 additions and 1 deletions
|
@ -111,8 +111,12 @@ func (s *Server) getEvents(ctx context.Context, w http.ResponseWriter, r *http.R
|
||||||
d := s.daemon
|
d := s.daemon
|
||||||
es := d.EventsService
|
es := d.EventsService
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
|
||||||
outStream := ioutils.NewWriteFlusher(w)
|
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)
|
enc := json.NewEncoder(outStream)
|
||||||
|
|
||||||
getContainerID := func(cn string) string {
|
getContainerID := func(cn string) string {
|
||||||
|
|
|
@ -40,6 +40,9 @@ func (daemon *Daemon) ContainerStats(prefixOrName string, config *ContainerStats
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.Stream {
|
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)
|
config.OutStream.Write(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue