Hi all,
I wish to implement a custom StreamAlgorithm whose parse() method can
potentially return false if the incoming request has not been received
completely into the input buffer. (For the curious, I'm trying to write a
custom protocol that handles the Typed Parameter Language
(tpl.sourceforge.net)).
However, when my StreamAlgorithm's parse() method returns false, the request
is not processed. I tried inspecting the ContentLengthAlgorithm's parse()
method, but found that this does not seem to work either. I create a simple
SelectorThread for the ContentLengthAlgorithm and POST a request that's
greater than the default buffer size of 8192 bytes. The request is never
processed.
Here's a (hopefully) concise example:
SelectorThread selectorThread = new SelectorThread() {
protected void initAlgorithm()
{
setAlgorithmClassName(
"com.sun.grizzly.http.algorithms.ContentLengthAlgorithm");
super.initAlgorithm();
}
};
selectorThread.setPort(80);
selectorThread.setAdapter( new StaticResourcesAdapter());
selectorThread.initEndpoint();
selectorThread.startEndpoint();
The client is:
URL url = new URL("
http://localhost/index.html");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
PrintWriter writer = new PrintWriter(conn.getOutputStream());
writer.print("param=");
for( int i = 0; i < 8000; i++ )
{
writer.print("data");
}
writer.close();
InputStream in = conn.getInputStream();
while( in.read() > 0 ) { System.out.print("."); }
System.out.println();
Am I missing some vital piece of configuration here, or am I
misunderstanding how the parse() method is supposed to work? By the way, I'm
using Grizzly 1.5.1 and am relatively new to using it.
Thanks,
-Eric