Skip to content

Commit

Permalink
Avoid sending errors in gob in storage requests (#10977)
Browse files Browse the repository at this point in the history
  • Loading branch information
vadmeste committed Nov 25, 2020
1 parent 2ff655a commit 91130e8
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions cmd/storage-rest-server.go
Expand Up @@ -18,7 +18,6 @@ package cmd

import (
"bufio"
"bytes"
"encoding/binary"
"encoding/gob"
"encoding/hex"
Expand Down Expand Up @@ -828,15 +827,8 @@ func streamHTTPResponse(w http.ResponseWriter) *httpStreamResponse {
ticker.Stop()
defer close(doneCh)
if err != nil {
var buf bytes.Buffer
enc := gob.NewEncoder(&buf)
if ee := enc.Encode(err); ee == nil {
w.Write([]byte{3})
w.Write(buf.Bytes())
} else {
w.Write([]byte{1})
w.Write([]byte(err.Error()))
}
w.Write([]byte{1})
w.Write([]byte(err.Error()))
} else {
w.Write([]byte{0})
}
Expand Down Expand Up @@ -882,7 +874,8 @@ func waitForHTTPStream(respBody io.ReadCloser, w io.Writer) error {
respBody.Close()
return errors.New(string(errorText))
case 3:
// Typed error
// gob style is already deprecated, we can remove this when
// storage API version will be greater or equal to 23.
defer respBody.Close()
dec := gob.NewDecoder(respBody)
var err error
Expand Down

0 comments on commit 91130e8

Please sign in to comment.