Commit 8176766d authored by Jeromy's avatar Jeromy

naming and cleanup

License: MIT
Signed-off-by: default avatarJeromy <jeromyj@gmail.com>
parent 0c4b10af
......@@ -204,14 +204,14 @@ func sendResponse(w http.ResponseWriter, req cmds.Request, res cmds.Response) {
h.Set(streamHeader, "1")
h.Set(transferEncodingHeader, "chunked")
if err := copyChunks(status, w, out); err != nil {
if err := writeResponse(status, w, out); err != nil {
log.Error("error while writing stream", err)
}
}
// Copies from an io.Reader to a http.ResponseWriter.
// Flushes chunks over HTTP stream as they are read (if supported by transport).
func copyChunks(status int, w http.ResponseWriter, out io.Reader) error {
func writeResponse(status int, w http.ResponseWriter, out io.Reader) error {
// hijack the connection so we can write our own chunked output and trailers
hijacker, ok := w.(http.Hijacker)
if !ok {
......@@ -283,19 +283,3 @@ func sanitizedErrStr(err error) string {
s = strings.Split(s, "\r")[0]
return s
}
type flushResponse struct {
W http.ResponseWriter
}
func (fr *flushResponse) Write(buf []byte) (int, error) {
n, err := fr.W.Write(buf)
if err != nil {
return n, err
}
if flusher, ok := fr.W.(http.Flusher); ok {
flusher.Flush()
}
return n, err
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment