Beispiel #1
0
    def to_bytes(self):

        type_byte = 0xc0

        if self.fin:
            type_byte ^= 0b00100000

        else:
            type_byte ^= 0b00010000

        offset_length = self._get_offset_length()

        if offset_length > 0:
            type_byte ^= offset_length << 2

        stream_id_len = self._get_sream_id_length()
        type_byte ^= stream_id_len

        stream_id = write_int(stream_id_len, self.stream_id)
        offset = write_int(offset_length, self.offset)
        data_len = write_int(2, len(self.payload))

        return write_int(
            1, type_byte) + stream_id + offset + data_len + self.payload
Beispiel #2
0
 def to_bytes(self):
     return (self.TYPE_BYTE + write_int(4, self.error) +
             write_int(2, len(self.reason)) + self.reason)
Beispiel #3
0
 def to_bytes(self):
     return (self.TYPE_BYTE + write_int(4, self.stream_id) +
             write_int(8, self.offset) + write_int(4, self.error))
Beispiel #4
0
    def to_bytes(self):
        type_byte = 0b10100000
        type_byte ^= 0b00010000
        type_byte ^= 0b00001100  # for simplicity, just use 6 bytes to encode largest_acknowledged
        type_byte ^= 0b00000011  # for simplicity, just use 6 bytes to encode ack_block

        ack_block_section = b''
        ack_block_section += write_int(6, self.ack_blocks[0])

        for gap, ack_block_len in self.ack_blocks[1:]:
            ack_block_section += write_int(1, gap) + write_int(
                6, ack_block_len)

        timestapm_section = b''
        if self.timestapms:
            delta_la, first_time_stamp = self.timestapms[0]
            timestapm_section += write_int(1, delta_la)
            timestapm_section += write_int(4, first_time_stamp)

        for delta_la_n, time_since_prev_n in self.timestapms[1:]:
            timestapm_section += write_int(1, delta_la_n)
            timestapm_section += write_ufloat16(time_since_prev_n)

        return (write_int(1, type_byte) + write_int(1, len(self.ack_blocks)) +
                write_int(1, len(self.timestapms)) +
                write_int(6, self.largest_acknowledged) +
                write_int(2, self.ack_delay) + ack_block_section +
                timestapm_section)
Beispiel #5
0
 def to_bytes(self):
     return (self.TYPE_BYTE + write_int(2, self.sequence) +
             write_int(2, self.connection_id))
Beispiel #6
0
 def to_bytes(self):
     return self.TYPE_BYTE + write_int(4, self.stream_id)
Beispiel #7
0
 def to_bytes(self):
     return self.TYPE_BYTE + write_int(4, self.max_data)
Beispiel #8
0
 def to_bytes(self):
     return (self.TYPE_BYTE + write_int(4, self.largest_client_stream_id) +
             write_int(4, self.largest_server_stream_id))