@@ -10,6 +10,7 @@ import (
10
10
"strings"
11
11
12
12
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/rs/cors"
13
+ context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
13
14
14
15
cmds "github.com/ipfs/go-ipfs/commands"
15
16
u "github.com/ipfs/go-ipfs/util"
@@ -119,7 +120,11 @@ func (i internalHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
119
120
120
121
//ps: take note of the name clash - commands.Context != context.Context
121
122
req .SetInvocContext (i .ctx )
122
- err = req .SetRootContext (node .Context ())
123
+
124
+ ctx , cancel := context .WithCancel (node .Context ())
125
+ defer cancel ()
126
+
127
+ err = req .SetRootContext (ctx )
123
128
if err != nil {
124
129
http .Error (w , err .Error (), http .StatusInternalServerError )
125
130
return
@@ -204,7 +209,12 @@ func sendResponse(w http.ResponseWriter, req cmds.Request, res cmds.Response) {
204
209
h .Set (transferEncodingHeader , "chunked" )
205
210
206
211
if err := writeResponse (status , w , out ); err != nil {
207
- log .Error ("error while writing stream" , err )
212
+ if strings .Contains (err .Error (), "broken pipe" ) {
213
+ log .Info ("client disconnect while writing stream " , err )
214
+ return
215
+ }
216
+
217
+ log .Error ("error while writing stream " , err )
208
218
}
209
219
}
210
220
0 commit comments