@@ -133,14 +133,6 @@ func (i internalHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
133
133
}
134
134
135
135
func guessMimeType (res cmds.Response ) (string , error ) {
136
- if _ , ok := res .Output ().(io.Reader ); ok {
137
- // we don't set the Content-Type for streams, so that browsers can MIME-sniff the type themselves
138
- // we set this header so clients have a way to know this is an output stream
139
- // (not marshalled command output)
140
- // TODO: set a specific Content-Type if the command response needs it to be a certain type
141
- return "" , nil
142
- }
143
-
144
136
// Try to guess mimeType from the encoding option
145
137
enc , found , err := res .Request ().Option (cmds .EncShort ).String ()
146
138
if err != nil {
@@ -182,6 +174,11 @@ func sendResponse(w http.ResponseWriter, req cmds.Request, res cmds.Response) {
182
174
h .Set (contentLengthHeader , strconv .FormatUint (res .Length (), 10 ))
183
175
}
184
176
177
+ if _ , ok := res .Output ().(io.Reader ); ok {
178
+ mime = ""
179
+ h .Set (streamHeader , "1" )
180
+ }
181
+
185
182
// if output is a channel and user requested streaming channels,
186
183
// use chunk copier for the output
187
184
_ , isChan := res .Output ().(chan interface {})
@@ -201,7 +198,6 @@ func sendResponse(w http.ResponseWriter, req cmds.Request, res cmds.Response) {
201
198
if mime != "" {
202
199
h .Set (contentTypeHeader , mime )
203
200
}
204
- h .Set (streamHeader , "1" )
205
201
h .Set (transferEncodingHeader , "chunked" )
206
202
207
203
if err := writeResponse (status , w , out ); err != nil {
0 commit comments