The best way is probably to replace the Response.Body before returning the 
result of http.ReadResponse() with an io.ReadCloser that also closes the 
underlying channel.

Replace the end of RoundTrip() with something like this (untested) code:
    resp := http.ReadResponse(bufio.NewReader(ch), req)
    resp.Body = channelCloser{ resp.Body, ch }
    return resp
}

type channelCloser struct {
io.ReadCloser
ch ssh.Channel
}
func (cc *channelCloser) Close() error {
    err := cc.ReadCloser.Close()
    err2 := cc.ch.Close()
    if err == nil {
        err = err2
    }
    return err
}

This way the channel is closed when the body of the response is closed, and 
no sooner.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to