H2DataFrame implements RFC7540 par6.1 This packet is the Data Frame to use when there is padding.
| 1442 | |
| 1443 | |
| 1444 | class H2PaddedDataFrame(H2DataFrame): |
| 1445 | """ H2DataFrame implements RFC7540 par6.1 |
| 1446 | This packet is the Data Frame to use when there is padding. |
| 1447 | """ |
| 1448 | __slots__ = ['s_len'] |
| 1449 | |
| 1450 | name = 'HTTP/2 Padded Data Frame' |
| 1451 | fields_desc = [ |
| 1452 | fields.FieldLenField('padlen', None, length_of='padding', fmt="B"), |
| 1453 | fields.StrLenField('data', '', |
| 1454 | length_from=lambda pkt: pkt.get_data_len() |
| 1455 | ), |
| 1456 | fields.StrLenField('padding', '', |
| 1457 | length_from=lambda pkt: pkt.getfieldval('padlen') |
| 1458 | ) |
| 1459 | ] |
| 1460 | |
| 1461 | def get_data_len(self): |
| 1462 | # type: () -> int |
| 1463 | """ get_data_len computes the length of the data field |
| 1464 | |
| 1465 | To do this computation, the length of the padlen field and the actual |
| 1466 | padding is subtracted to the string that was provided to the pre_dissect # noqa: E501 |
| 1467 | fun of the pkt parameter |
| 1468 | :return: int; length of the data part of the HTTP/2 frame packet provided as parameter # noqa: E501 |
| 1469 | :raises: AssertionError |
| 1470 | """ |
| 1471 | padding_len = self.getfieldval('padlen') |
| 1472 | fld, fval = self.getfield_and_val('padlen') |
| 1473 | padding_len_len = fld.i2len(self, fval) |
| 1474 | |
| 1475 | ret = self.s_len - padding_len_len - padding_len |
| 1476 | assert ret >= 0 |
| 1477 | return ret |
| 1478 | |
| 1479 | def pre_dissect(self, s): |
| 1480 | # type: (str) -> str |
| 1481 | """pre_dissect is filling the s_len property of this instance. This |
| 1482 | property is later used during the getfield call of the "data" field when # noqa: E501 |
| 1483 | trying to evaluate the length of the StrLenField! This "trick" works |
| 1484 | because the underlayer packet (H2Frame) is assumed to override the |
| 1485 | "extract_padding" method and to only provide to this packet the data |
| 1486 | necessary for this packet. Tricky, tricky, will break some day probably! # noqa: E501 |
| 1487 | """ |
| 1488 | self.s_len = len(s) |
| 1489 | return s |
| 1490 | |
| 1491 | |
| 1492 | # HTTP/2 Header Frame Packets # # noqa: E501 |
nothing calls this directly
no test coverage detected
searching dependent graphs…