naming and cleanup
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
Jeromy committed
Jul 27, 2015 at 17:25 UTC
8176766d5ac0f972383d3d6ef677c19d696c7e8d
1 file changed
+2
-18
commands/http/handler.go
+2
-18
@@ -204,14 +204,14 @@ func sendResponse(w http.ResponseWriter, req cmds.Request, res cmds.Response) {
204
h.Set(streamHeader, "1")
205
h.Set(transferEncodingHeader, "chunked")
206
207
- if err := copyChunks(status, w, out); err != nil {
207
+ if err := writeResponse(status, w, out); err != nil {
208
log.Error("error while writing stream", err)
209
}
210
}
211
212
// Copies from an io.Reader to a http.ResponseWriter.
213
// Flushes chunks over HTTP stream as they are read (if supported by transport).
214
-func copyChunks(status int, w http.ResponseWriter, out io.Reader) error {
214
+func writeResponse(status int, w http.ResponseWriter, out io.Reader) error {
215
// hijack the connection so we can write our own chunked output and trailers
216
hijacker, ok := w.(http.Hijacker)
217
if !ok {
@@ -283,19 +283,3 @@ func sanitizedErrStr(err error) string {
283
s = strings.Split(s, "\r")[0]
284
return s
285
}
286
-
287
-type flushResponse struct {
288
- W http.ResponseWriter
289
-}
290
-
291
-func (fr *flushResponse) Write(buf []byte) (int, error) {
292
- n, err := fr.W.Write(buf)
293
- if err != nil {
294
- return n, err
295
- }
296
-
297
- if flusher, ok := fr.W.(http.Flusher); ok {
298
- flusher.Flush()
299
- }
300
- return n, err
301
-}