GoogleCloudPlatform/kubernetes — pull request #889 by smarterclayton (2014-08-13 22:56:19+00:00)
Title: Allow watch operations to run longer than the http.Server timeout

The default http.Server implementation sets a global write deadline
on all handled responses. Watches depend on waiting for long periods
before returning. A watch implementation should be able to wait
longer than the default server timeout.

This commit alters watch to hijack the http response writer, gain
access to the underlying connection for setting the write deadline
(which must be reset after every write), and also properly handle
chunked encoding of the http response (it's not possible to game
the write deadline via the ResponseWriter by writing empty lines
because we don't know what the servers deadline is set to).