def common_header(frame)
      header = []

      unless FRAME_TYPES[frame[:type]]
        fail CompressionError, "Invalid frame type (#{frame[:type]})"
      end

      if frame[:length] > @max_frame_size
        fail CompressionError, "Frame size is too large: #{frame[:length]}"
      end

      if frame[:length] < 0
        fail CompressionError, "Frame size is invalid: #{frame[:length]}"
      end

      if frame[:stream] > MAX_STREAM_ID
        fail CompressionError, "Stream ID (#{frame[:stream]}) is too large"
      end

      if frame[:type] == :window_update && frame[:increment] > MAX_WINDOWINC
        fail CompressionError, "Window increment (#{frame[:increment]}) is too large"
      end

      header << (frame[:length] >> FRAME_LENGTH_HISHIFT)
      header << (frame[:length] & FRAME_LENGTH_LOMASK)
      header << FRAME_TYPES[frame[:type]]
      header << frame[:flags].reduce(0) do |acc, f|
        position = FRAME_FLAGS[frame[:type]][f]
        unless position
          fail CompressionError, "Invalid frame flag (#{f}) for #{frame[:type]}"
        end

        acc | (1 << position)
      end

      header << frame[:stream]
      header.pack(HEADERPACK) # 8+16,8,8,32
    end
def common_header(frame)
      header = []

      unless FRAME_TYPES[frame[:type]]
        fail CompressionError, "Invalid frame type (#{frame[:type]})"
      end

      if frame[:length] > @max_frame_size
        fail CompressionError, "Frame size is too large: #{frame[:length]}"
      end

      if frame[:length] < 0
        fail CompressionError, "Frame size is invalid: #{frame[:length]}"
      end

      if frame[:stream] > MAX_STREAM_ID
        fail CompressionError, "Stream ID (#{frame[:stream]}) is too large"
      end

      if frame[:type] == :window_update && frame[:increment] > MAX_WINDOWINC
        fail CompressionError, "Window increment (#{frame[:increment]}) is too large"
      end

      header << (frame[:length] >> FRAME_LENGTH_HISHIFT)
      header << (frame[:length] & FRAME_LENGTH_LOMASK)
      header << FRAME_TYPES[frame[:type]]
      header << frame[:flags].reduce(0) do |acc, f|
        position = FRAME_FLAGS[frame[:type]][f]
        unless position
          fail CompressionError, "Invalid frame flag (#{f}) for #{frame[:type]}"
        end

        acc | (1 << position)
      end

      header << frame[:stream]
      header.pack(HEADERPACK) # 8+16,8,8,32
    end
Initializes new framer object.

 Generates common 9-byte frame header.
 - http://tools.ietf.org/html/draft-ietf-httpbis-http2-16#section-4.1

 @param frame [Hash]
 @return [String]