I'm trying to use a "ServerSocket" to receive HTTP messages from a client which is POSTing them as chunked. I just want to capture the text content being posted (plain text). Any input on how to do this better would be welcomed.
Here is my existing and very not-elegant solution. When dealing with ServerSocket, one has to handle the headers and chunk barriers manually, and this is what I came up with. I looked at filterline method on the reader, maybe that's part of a solution, i'm not sure. socket.withStreams { input, output -> BufferedReader reader = new BufferedReader(new InputStreamReader(input)) while (currentLineCount < processor.newLineCount) { line = reader.readLine() if (line && line.size() > 3) { processor.processFormats(line) } currentLineCount++ } } Caveats: 1. I have been trying to process line by line to minimize memory impact, rather than buffering the whole collection. I'd like to keep it that way. 2. These 4 Jetty libraries are available on the classpath, so I could leverage them, but can't add other libraries. compile 'org.eclipse.jetty:jetty-server:8.1.2.v20120308' compile 'org.eclipse.jetty:jetty-continuation:8.1.2.v20120308' compile 'org.eclipse.jetty:jetty-io:8.1.2.v20120308' compile 'org.eclipse.jetty:jetty-util:8.1.2.v20120308' I would make the Service and Handler in Jetty, but I can't find any good examples that fit my situation. Gerald R. Wiltse jerrywil...@gmail.com