mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Implementing Flush method to httplog
This commit is contained in:
		@@ -161,6 +161,16 @@ func (rl *respLogger) Write(b []byte) (int, error) {
 | 
				
			|||||||
	return rl.w.Write(b)
 | 
						return rl.w.Write(b)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Flush implements http.Flusher even if the underlying http.Writer doesn't implement it.
 | 
				
			||||||
 | 
					// Flush is used for streaming purposes and allows to flush buffered data to the client.
 | 
				
			||||||
 | 
					func (rl *respLogger) Flush() {
 | 
				
			||||||
 | 
						if flusher, ok := rl.w.(http.Flusher); ok {
 | 
				
			||||||
 | 
							flusher.Flush()
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							glog.V(2).Infof("Unable to convert %v into http.Flusher", rl.w)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// WriteHeader implements http.ResponseWriter.
 | 
					// WriteHeader implements http.ResponseWriter.
 | 
				
			||||||
func (rl *respLogger) WriteHeader(status int) {
 | 
					func (rl *respLogger) WriteHeader(status int) {
 | 
				
			||||||
	rl.status = status
 | 
						rl.status = status
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -212,8 +212,10 @@ func (s *Server) handleContainerLogs(w http.ResponseWriter, req *http.Request) {
 | 
				
			|||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fw := FlushWriter{writer: w}
 | 
						fw := FlushWriter{writer: w}
 | 
				
			||||||
	if flusher, ok := w.(http.Flusher); ok {
 | 
						if flusher, ok := fw.writer.(http.Flusher); ok {
 | 
				
			||||||
		fw.flusher = flusher
 | 
							fw.flusher = flusher
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							s.error(w, fmt.Errorf("Unable to convert %v into http.Flusher", fw))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	w.Header().Set("Transfer-Encoding", "chunked")
 | 
						w.Header().Set("Transfer-Encoding", "chunked")
 | 
				
			||||||
	w.WriteHeader(http.StatusOK)
 | 
						w.WriteHeader(http.StatusOK)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user