Takahiro Suzuki | d7bf820 | 2020-12-17 20:21:59 +0900 | [diff] [blame] | 1 | package sarama |
| 2 | |
| 3 | import "fmt" |
| 4 | |
| 5 | const responseLengthSize = 4 |
| 6 | const correlationIDSize = 4 |
| 7 | |
| 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 | } |