mirror of
https://github.com/LBRYFoundation/reflector.go.git
synced 2025-08-23 17:27:25 +00:00
send the expected response instead of the error message
This commit is contained in:
parent
65df7bc627
commit
fe9cf091fc
1 changed files with 14 additions and 5 deletions
|
@ -150,11 +150,12 @@ func (s *Server) doError(conn net.Conn, err error) error {
|
||||||
if e2, ok := err.(*json.SyntaxError); ok {
|
if e2, ok := err.(*json.SyntaxError); ok {
|
||||||
log.Errorf("syntax error at byte offset %d", e2.Offset)
|
log.Errorf("syntax error at byte offset %d", e2.Offset)
|
||||||
}
|
}
|
||||||
resp, err := json.Marshal(errorResponse{Error: err.Error()})
|
//resp, err := json.Marshal(errorResponse{Error: err.Error()})
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
//}
|
||||||
return s.write(conn, resp)
|
//return s.write(conn, resp)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) receiveBlob(conn net.Conn) error {
|
func (s *Server) receiveBlob(conn net.Conn) error {
|
||||||
|
@ -196,11 +197,19 @@ func (s *Server) receiveBlob(conn net.Conn) error {
|
||||||
|
|
||||||
blob, err := s.readRawBlob(conn, blobSize)
|
blob, err := s.readRawBlob(conn, blobSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
sendErr := s.sendTransferResponse(conn, false, isSdBlob)
|
||||||
|
if sendErr != nil {
|
||||||
|
return sendErr
|
||||||
|
}
|
||||||
return errors.Prefix("error reading blob "+blobHash[:8], err)
|
return errors.Prefix("error reading blob "+blobHash[:8], err)
|
||||||
}
|
}
|
||||||
|
|
||||||
receivedBlobHash := BlobHash(blob)
|
receivedBlobHash := BlobHash(blob)
|
||||||
if blobHash != receivedBlobHash {
|
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")
|
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
|
// this can also happen if the blob size is wrong, because the server will read the wrong number of bytes from the stream
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue