Пример #1
0
    def get_frame_bin(self):

        if self._data is None and not self.is_ack:  # If user didn't set data

            self._data = bytearray()

            for setting in self._setting_list:

                # set identifier 16 bit

                self._data.append((setting[0] & 0x0000FF00) >> 8)

                self._data.append((setting[0] & 0x000000FF) >> 0)

                # set value 32 bit

                self._data.append((setting[1] & 0xFF000000) >> 24)

                self._data.append((setting[1] & 0x00FF0000) >> 16)

                self._data.append((setting[1] & 0x0000FF00) >> 8)

                self._data.append((setting[1] & 0x000000FF) >> 0)

        elif self.is_ack:  # if ACK SETTINGS frame clear payload
            self._data = bytearray()
            self._flag = SettingFrame.ACK_FLAG

        # call super get_frame_bin

        return Frame.get_frame_bin(self)
Пример #2
0
    def get_frame_bin(self):

        # Encode header

        encoder = Encoder()

        headers_frame_field = bytearray()

        if self._data is None:  # if user didn't touch data
            self._data = encoder.encode(self._header_list)  # encode header list

        self._flag = self.flag  # get flag by method

        if self._is_padded:

            headers_frame_field.append(self._pad_len)  # append pad length

            self._data += bytearray(self._pad_len)  # append pad byte in pad length

        if self._is_priority:
            headers_frame_field += int_to_bytes(self._dependency_id, 4)  # append dependency stream id
            headers_frame_field.append(self._weight)

        self._data = headers_frame_field + self._data  # append HEADERS field

        return Frame.get_frame_bin(self)
Пример #3
0
    def get_frame_bin(self):

        if self._data is None:  # if user didn't touch data
            self._data = bytearray()
            self._data += int_to_bytes(self._dependency_id)  # append dependency stream id
            self._data.append(self._weight)

        return Frame.get_frame_bin(self)
Пример #4
0
    def get_frame_bin(self):

        if self._data is None:  # if user didn't touch data
            self._data = bytearray()
            self._data += self.opaque

        if self.ack:
            self._flag = 0x1

        return Frame.get_frame_bin(self)
Пример #5
0
    def get_frame_bin(self):

        if self._data is None:
            self._data = bytearray()
            self._data += int_to_bytes(self.last_stream_id, 4)
            self._data += int_to_bytes(self.error_code, 4)

            self._data = self.debug_data.encode(GoawayFrame.GOAWAY_DEBUG_ENCODING)

        return Frame.get_frame_bin(self)
Пример #6
0
    def get_frame_bin(self):

        headers_frame_field = bytearray()

        if self._data is None:
            self._data = bytearray()  # check for safe

        self._flag = self.flag  # get flag by method

        if self._is_padded:

            headers_frame_field.append(self._pad_len)  # append pad length

            self._data += bytearray(self._pad_len)  # append pad byte in pad length

        self._data = headers_frame_field + self._data  # append HEADERS field

        return Frame.get_frame_bin(self)
Пример #7
0
    def get_frame_bin(self):

        if self._data is None:  # if user didn't touch data
            self._data = int_to_bytes(self.error_code, 4)

        return Frame.get_frame_bin(self)
Пример #8
0
    def get_frame_bin(self):

        if self._data is None:
            self._data = int_to_bytes(self.window_size, 4)

        return Frame.get_frame_bin(self)