Skip to content

Commit

Permalink
send the expected response instead of the error message
Browse files Browse the repository at this point in the history
  • Loading branch information
lyoshenka committed Aug 20, 2018
1 parent 65df7bc commit fe9cf09
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions reflector/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,12 @@ func (s *Server) doError(conn net.Conn, err error) error {
if e2, ok := err.(*json.SyntaxError); ok {
log.Errorf("syntax error at byte offset %d", e2.Offset)
}
resp, err := json.Marshal(errorResponse{Error: err.Error()})
if err != nil {
return err
}
return s.write(conn, resp)
//resp, err := json.Marshal(errorResponse{Error: err.Error()})
//if err != nil {
// return err
//}
//return s.write(conn, resp)
return nil
}

func (s *Server) receiveBlob(conn net.Conn) error {
Expand Down Expand Up @@ -196,11 +197,19 @@ func (s *Server) receiveBlob(conn net.Conn) error {

blob, err := s.readRawBlob(conn, blobSize)
if err != nil {
sendErr := s.sendTransferResponse(conn, false, isSdBlob)
if sendErr != nil {
return sendErr
}
return errors.Prefix("error reading blob "+blobHash[:8], err)
}

receivedBlobHash := BlobHash(blob)
if blobHash != receivedBlobHash {
sendErr := s.sendTransferResponse(conn, false, isSdBlob)
if sendErr != nil {
return sendErr
}
return errors.Err("hash of received blob data does not match hash from send request")
// this can also happen if the blob size is wrong, because the server will read the wrong number of bytes from the stream
}
Expand Down

0 comments on commit fe9cf09

Please sign in to comment.