response_header.go 611 B

12345678910111213141516171819202122232425262728293031
  1. package sarama
  2. import "fmt"
  3. const responseLengthSize = 4
  4. const correlationIDSize = 4
  5. type responseHeader struct {
  6. length int32
  7. correlationID int32
  8. }
  9. func (r *responseHeader) decode(pd packetDecoder, version int16) (err error) {
  10. r.length, err = pd.getInt32()
  11. if err != nil {
  12. return err
  13. }
  14. if r.length <= 4 || r.length > MaxResponseSize {
  15. return PacketDecodingError{fmt.Sprintf("message of length %d too large or too small", r.length)}
  16. }
  17. r.correlationID, err = pd.getInt32()
  18. if version >= 1 {
  19. if _, err := pd.getEmptyTaggedFieldArray(); err != nil {
  20. return err
  21. }
  22. }
  23. return err
  24. }