private HttpCmdRequest parseRequest() throws Exception {

        BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream(), "UTF-8"));

        StringTokenizer st = new StringTokenizer(in.readLine());
        if (!st.hasMoreTokens())
            sendError(HTTP_BADREQUEST, "BAD REQUEST: Syntax error");

        String method = st.nextToken();

        if (!st.hasMoreTokens())
            sendError(HTTP_BADREQUEST, "BAD REQUEST: Missing URI");

        String uri = st.nextToken();

        Properties params = new Properties();
        assert uri != null;
        int qmi = uri.indexOf('?');
        if (qmi >= 0) {
            decodeParams(uri.substring(qmi + 1), params);
            uri = uri.substring(0, qmi);
        }

        Properties header = new Properties();
        if (st.hasMoreTokens()) {
            String line = in.readLine();
            while (line.trim().length() > 0) {
                int p = line.indexOf(':');
                header.put(line.substring(0, p).trim().toLowerCase(), line.substring(p + 1).trim());
                line = in.readLine();
            }
        }

        if (method.equalsIgnoreCase("POST")) {
            long size = 0x7FFFFFFFFFFFFFFFL;
            String contentLength = header.getProperty("Content-Length");
            if (contentLength == null) {
                contentLength = header.getProperty("content-length");
            }
            if (contentLength != null) {
                size = Integer.parseInt(contentLength);
            }
            String postLine = "";
            char buf[] = new char[512];
            int read = in.read(buf);
            while (read >= 0 && size > 0 && !postLine.endsWith("\r\n")) {
                size -= read;
                postLine += String.valueOf(buf, 0, read);
                if (size > 0)
                    read = in.read(buf);
            }
            postLine = postLine.trim();
            decodeParams(postLine, params);
        }
        return resolveRequest(uri, params);
    }
@author Robert HG (254963746@qq.com)  on 2/17/16.
lts-core/src/main/java/com/github/ltsopensource/cmd/HttpCmdExecutor.java