Unpacks the service parameters from the given offset.
(data: bytes, offset: int)
| 74 | |
| 75 | |
| 76 | def _unpack_params(data: bytes, offset: int) -> dict[int, bytes]: |
| 77 | """Unpacks the service parameters from the given offset.""" |
| 78 | params = {} |
| 79 | while offset < len(data): |
| 80 | param_type = struct.unpack("!H", data[offset : offset + 2])[0] |
| 81 | offset += 2 |
| 82 | param_length = struct.unpack("!H", data[offset : offset + 2])[0] |
| 83 | offset += 2 |
| 84 | if offset + param_length > len(data): |
| 85 | raise struct.error( |
| 86 | "unpack requires a buffer of %i bytes" % (offset + param_length) |
| 87 | ) |
| 88 | param_value = data[offset : offset + param_length] |
| 89 | offset += param_length |
| 90 | params[param_type] = param_value |
| 91 | return params |
| 92 | |
| 93 | |
| 94 | def unpack(data: bytes) -> HTTPSRecord: |