private void putMessage(final Request jettyRequest, final HttpServletResponse response) throws IOException {
        final String topic = jettyRequest.getParameter("topic");
        try {
            // Validation should be done on client side already
            final int partition = Integer.parseInt(jettyRequest.getParameter("partition"));
            final int flag = Integer.parseInt(jettyRequest.getParameter("flag"));
            int checkSum = -1;
            if (StringUtils.isNotBlank(jettyRequest.getParameter("checksum"))) {
                checkSum = Integer.parseInt(jettyRequest.getParameter("checksum"));
            }
            // This stream should be handle by Jetty server and therefore it is
            // out of scope here without care close
            final InputStream inputStream = jettyRequest.getInputStream();
            final int dataLength = Integer.parseInt(jettyRequest.getParameter("length"));
            final byte[] data = new byte[dataLength];

            inputStream.read(data);
            this.doResponseHeaders(response, "text/plain");
            final PutCommand putCommand = this.convert2PutCommand(topic, partition, data, flag, checkSum);
            this.commandProcessor.processPutCommand(putCommand, null, new PutCallback() {

                @Override
                public void putComplete(final ResponseCommand resp) {
                    final BooleanCommand responseCommand = (BooleanCommand) resp;
                    response.setStatus(responseCommand.getCode());
                    try {
                        response.getWriter().write(responseCommand.getErrorMsg());
                    }
                    catch (final IOException e) {
                        logger.error("Write response failed", e);
                    }

                }
            });

        }
        catch (final Exception e) {
            logger.error("Put message failed", e);
            response.setStatus(HttpStatus.InternalServerError);
            response.getWriter().write(e.getMessage());
        }
    }
Use Jetty as http server and handle request of get message/put message/get
offset
metamorphosis-server-wrapper/src/main/java/com/taobao/metamorphosis/http/processor/MetamorphosisOnJettyProcessor.java