Ejemplo n.º 1
0
 private void readSettingsFrame(
     ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener)
     throws Http2Exception {
   if (flags.ack()) {
     listener.onSettingsAckRead(ctx);
   } else {
     int numSettings = payloadLength / SETTING_ENTRY_LENGTH;
     Http2Settings settings = new Http2Settings();
     for (int index = 0; index < numSettings; ++index) {
       char id = (char) payload.readUnsignedShort();
       long value = payload.readUnsignedInt();
       try {
         settings.put(id, Long.valueOf(value));
       } catch (IllegalArgumentException e) {
         switch (id) {
           case SETTINGS_MAX_FRAME_SIZE:
             throw connectionError(FRAME_SIZE_ERROR, e, e.getMessage());
           case SETTINGS_INITIAL_WINDOW_SIZE:
             throw connectionError(FLOW_CONTROL_ERROR, e, e.getMessage());
           default:
             throw connectionError(PROTOCOL_ERROR, e, e.getMessage());
         }
       }
     }
     listener.onSettingsRead(ctx, settings);
   }
 }