khenaidoo | ac63710 | 2019-01-14 15:44:34 -0500 | [diff] [blame] | 1 | package sarama |
| 2 | |
| 3 | import "fmt" |
| 4 | |
Scott Baker | beb3cfa | 2019-10-01 14:44:30 -0700 | [diff] [blame] | 5 | const responseLengthSize = 4 |
| 6 | const correlationIDSize = 4 |
| 7 | |
khenaidoo | ac63710 | 2019-01-14 15:44:34 -0500 | [diff] [blame] | 8 | type responseHeader struct { |
| 9 | length int32 |
| 10 | correlationID int32 |
| 11 | } |
| 12 | |
| 13 | func (r *responseHeader) decode(pd packetDecoder) (err error) { |
| 14 | r.length, err = pd.getInt32() |
| 15 | if err != nil { |
| 16 | return err |
| 17 | } |
| 18 | if r.length <= 4 || r.length > MaxResponseSize { |
| 19 | return PacketDecodingError{fmt.Sprintf("message of length %d too large or too small", r.length)} |
| 20 | } |
| 21 | |
| 22 | r.correlationID, err = pd.getInt32() |
| 23 | return err |
| 24 | } |