Skip to content

Commit 8176766

Browse files
committedJul 28, 2015
naming and cleanup
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
1 parent 0c4b10a commit 8176766

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed
 

‎commands/http/handler.go

+2-18
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,14 @@ func sendResponse(w http.ResponseWriter, req cmds.Request, res cmds.Response) {
204204
h.Set(streamHeader, "1")
205205
h.Set(transferEncodingHeader, "chunked")
206206

207-
if err := copyChunks(status, w, out); err != nil {
207+
if err := writeResponse(status, w, out); err != nil {
208208
log.Error("error while writing stream", err)
209209
}
210210
}
211211

212212
// Copies from an io.Reader to a http.ResponseWriter.
213213
// 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 {
215215
// hijack the connection so we can write our own chunked output and trailers
216216
hijacker, ok := w.(http.Hijacker)
217217
if !ok {
@@ -283,19 +283,3 @@ func sanitizedErrStr(err error) string {
283283
s = strings.Split(s, "\r")[0]
284284
return s
285285
}
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-
}

0 commit comments

Comments
 (0)
Please sign in to comment.