response_header.go 553 B

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