def validate_settings(role, settings)
      settings.each do |key, v|
        case key
        when :settings_header_table_size
          # Any value is valid
        when :settings_enable_push
          case role
          when :server
            # Section 8.2
            # Clients MUST reject any attempt to change the
            # SETTINGS_ENABLE_PUSH setting to a value other than 0 by treating the
            # message as a connection error (Section 5.4.1) of type PROTOCOL_ERROR.
            return ProtocolError.new("invalid #{key} value") unless v.zero?
          when :client
            # Any value other than 0 or 1 MUST be treated as a
            # connection error (Section 5.4.1) of type PROTOCOL_ERROR.
            unless v.zero? || v == 1
              return ProtocolError.new("invalid #{key} value")
            end
          end
        when :settings_max_concurrent_streams
          # Any value is valid
        when :settings_initial_window_size
          # Values above the maximum flow control window size of 2^31-1 MUST
          # be treated as a connection error (Section 5.4.1) of type
          # FLOW_CONTROL_ERROR.
          unless v <= 0x7fffffff
            return FlowControlError.new("invalid #{key} value")
          end
        when :settings_max_frame_size
          # The initial value is 2^14 (16,384) octets.  The value advertised
          # by an endpoint MUST be between this initial value and the maximum
          # allowed frame size (2^24-1 or 16,777,215 octets), inclusive.
          # Values outside this range MUST be treated as a connection error
          # (Section 5.4.1) of type PROTOCOL_ERROR.
          unless v >= 16_384 && v <= 16_777_215
            return ProtocolError.new("invalid #{key} value")
          end
        when :settings_max_header_list_size
          # Any value is valid
          # else # ignore unknown settings
        end
      end
      nil
    end
def validate_settings(role, settings)
      settings.each do |key, v|
        case key
        when :settings_header_table_size
          # Any value is valid
        when :settings_enable_push
          case role
          when :server
            # Section 8.2
            # Clients MUST reject any attempt to change the
            # SETTINGS_ENABLE_PUSH setting to a value other than 0 by treating the
            # message as a connection error (Section 5.4.1) of type PROTOCOL_ERROR.
            return ProtocolError.new("invalid #{key} value") unless v.zero?
          when :client
            # Any value other than 0 or 1 MUST be treated as a
            # connection error (Section 5.4.1) of type PROTOCOL_ERROR.
            unless v.zero? || v == 1
              return ProtocolError.new("invalid #{key} value")
            end
          end
        when :settings_max_concurrent_streams
          # Any value is valid
        when :settings_initial_window_size
          # Values above the maximum flow control window size of 2^31-1 MUST
          # be treated as a connection error (Section 5.4.1) of type
          # FLOW_CONTROL_ERROR.
          unless v <= 0x7fffffff
            return FlowControlError.new("invalid #{key} value")
          end
        when :settings_max_frame_size
          # The initial value is 2^14 (16,384) octets.  The value advertised
          # by an endpoint MUST be between this initial value and the maximum
          # allowed frame size (2^24-1 or 16,777,215 octets), inclusive.
          # Values outside this range MUST be treated as a connection error
          # (Section 5.4.1) of type PROTOCOL_ERROR.
          unless v >= 16_384 && v <= 16_777_215
            return ProtocolError.new("invalid #{key} value")
          end
        when :settings_max_header_list_size
          # Any value is valid
          # else # ignore unknown settings
        end
      end
      nil
    end
Validate settings parameters.  See sepc Section 6.5.2.

 @param role [Symbol] The sender's role: :client or :server
 @return nil if no error.  Exception object in case of any error.