class Protocol::HPACK::Context

def decode(command)

Returns:
  • (Array) - +[name, value]+ header field that is added to the decoded header list

Parameters:
  • command (Hash) -- {type:, name:, value:, index:}
def decode(command)
	emit = nil
	case command[:type]
	when :change_table_size
		self.table_size = command[:value]
	when :indexed
		# Indexed Representation
		# An _indexed representation_ entails the following actions:
		# o  The header field corresponding to the referenced entry in either
		# the static table or dynamic table is added to the decoded header
		# list.
		idx = command[:name]
		k, v = dereference(idx)
		emit = [k, v]
	when :incremental, :no_index, :never_indexed
		# A _literal representation_ that is _not added_ to the dynamic table
		# entails the following action:
		# o  The header field is added to the decoded header list.
		# A _literal representation_ that is _added_ to the dynamic table
		# entails the following actions:
		# o  The header field is added to the decoded header list.
		# o  The header field is inserted at the beginning of the dynamic table.
		if command[:name].is_a? Integer
			k, v = dereference(command[:name])
			command = command.dup
			command[:index] ||= command[:name]
			command[:value] ||= v
			command[:name] = k
		end
		emit = [command[:name], command[:value]]
		add_to_table(emit) if command[:type] == :incremental
	else
		raise CompressionError, "Invalid type: #{command[:type]}"
	end
	return emit
end