commands/http: Respond with error if encoding option isn't a string
Matt Bell committed
Nov 3, 2014 at 20:02 UTC
4552fce5171843123549da759ad164005dac3240
1 file changed
+6
-1
commands/http/handler.go
+6
-1
@@ -43,7 +43,12 @@ func (i Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
43
w.Header().Set("Content-Type", "application/octet-stream")
44
} else {
45
enc, _ := req.Option(cmds.EncShort)
46
- mime := mimeTypes[enc.(string)]
46
+ encStr, ok := enc.(string)
47
+ if !ok {
48
+ w.WriteHeader(http.StatusInternalServerError)
49
+ return
50
+ }
51
+ mime := mimeTypes[encStr]
52
w.Header().Set("Content-Type", mime)
53
}
54