@Handler
    public void onInput(Input<ByteBuffer> event, IOSubchannel channel)
            throws InterruptedException, UnsupportedEncodingException {
        Optional<FormContext> ctx = channel.associated(this, FormContext.class);
        if (!ctx.isPresent()) {
            return;
        }
        ctx.get().fieldDecoder.addData(event.data());
        if (!event.isEndOfRecord()) {
            return;
        }

        long invocations = (Long) ctx.get().session.computeIfAbsent(
            "invocations", key -> {
                return 0L;
            });
        ctx.get().session.put("invocations", invocations + 1);

        HttpResponse response = ctx.get().request.response().get();
        response.setStatus(HttpStatus.OK);
        response.setHasPayload(true);
        response.setField(HttpField.CONTENT_TYPE,
            MediaType.builder().setType("text", "plain")
                .setParameter("charset", "utf-8").build());
        String data = "First name: "
            + ctx.get().fieldDecoder.fields().get("firstname")
            + "\r\n" + "Last name: "
            + ctx.get().fieldDecoder.fields().get("lastname")
            + "\r\n" + "Previous invocations: " + invocations;
        channel.respond(new Response(response));
        ManagedBuffer<ByteBuffer> out = channel.byteBufferPool().acquire();
        out.backingBuffer().put(data.getBytes("utf-8"));
        channel.respond(Output.fromSink(out, true));
    }
@ Handler public void onInput ( Input < ByteBuffer > event , IOSubchannel channel ) throws InterruptedException , UnsupportedEncodingException { Optional < FormContext > ctx = channel . associated ( this , FormContext . class ) ; if ( ! ctx . isPresent ( ) ) { return ; } ctx . get ( ) . fieldDecoder . addData ( event . data ( ) ) ; if ( ! event . isEndOfRecord ( ) ) { return ; } long invocations = ( Long ) ctx . get ( ) . session . computeIfAbsent ( "invocations" , key -> { return 0L ; } ) ; ctx . get ( ) . session . put ( "invocations" , invocations + 1 ) ; HttpResponse response = ctx . get ( ) . request . response ( ) . get ( ) ; response . setStatus ( HttpStatus . OK ) ; response . setHasPayload ( true ) ; response . setField ( HttpField . CONTENT_TYPE , MediaType . builder ( ) . setType ( "text" , "plain" ) . setParameter ( "charset" , "utf-8" ) . build ( ) ) ; String data = "First name: " + ctx . get ( ) . fieldDecoder . fields ( ) . get ( "firstname" ) + "\r\n" + "Last name: " + ctx . get ( ) . fieldDecoder . fields ( ) . get ( "lastname" ) + "\r\n" + "Previous invocations: " + invocations ; channel . respond ( new Response ( response ) ) ; ManagedBuffer < ByteBuffer > out = channel . byteBufferPool ( ) . acquire ( ) ; out . backingBuffer ( ) . put ( data . getBytes ( "utf-8" ) ) ; channel . respond ( Output . fromSink ( out , true ) ) ; }
Hanlde input.

@param event the event
@param channel the channel
@throws InterruptedException the interrupted exception
@throws UnsupportedEncodingException the unsupported encoding exception