Salut,
I've just added two new tests case and they both pass with the current
trunk:
> Test: testKeepAliveNotFoundTest
> Nov 5, 2009 6:43:00 PM com.sun.grizzly.http.SelectorThread displayConfiguration
> INFO:
> Grizzly running on Mac OS X-10.5.8 under JDK version: 1.5.0_20-Apple Inc.
> port: 0
> Thread Pool: StatsThreadPool[name=Grizzly-0, min-threads=5, max-threads=5, max-queue-size=4096, is-shutdown=false, port=0]
> Read Selector: -1
> ByteBuffer size: 8192
> maxHttpHeaderSize: 8192
> sendBufferSize: 131072
> maxKeepAliveRequests: 0
> keepAliveTimeoutInSeconds: 30
> Static File Cache enabled: true
> Static resources directory: /Users/jfarcand/workspace/grizzly/trunk/modules/http
> Adapter : com.sun.grizzly.http.BasicSelectorThreadTest$NotFoundAdapter
> Asynchronous Request Processing enabled: false
> Nov 5, 2009 6:43:00 PM com.sun.grizzly.Controller logVersion
> INFO: Starting Grizzly Framework 1.9.19-SNAPSHOT - Thu Nov 05 18:43:00 EST 2009
> Nov 5, 2009 6:43:00 PM com.sun.grizzly.http.ProcessorTask parseRequest
> INFO: SocketChannel request line java.nio.channels.SocketChannel[connected local=/127.0.0.1:60388 remote=/127.0.0.1:60389] is: R( /404.html)
> Nov 5, 2009 6:43:00 PM com.sun.grizzly.http.ProcessorTask parseRequest
> INFO: SocketChannel headersjava.nio.channels.SocketChannel[connected local=/127.0.0.1:60388 remote=/127.0.0.1:60389] are:
> === MimeHeaders ===
> user-agent = Java/1.5.0_20
> host = localhost:60388
> accept = text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
> connection = keep-alive
>
> Nov 5, 2009 6:43:00 PM com.sun.grizzly.http.SocketChannelOutputBuffer flushChannel
> INFO: HTTP/1.1 404 Not Found
> Content-Length: 0
> Date: Thu, 05 Nov 2009 23:42:59 GMT
> Connection: close
I suspect your Adapter is not setting the proper status code. The test
looks like:
> public void testKeepAliveNotFoundTest() throws Exception{
> System.out.println("Test: testKeepAliveNotFoundTest");
> try {
> createSelectorThread(0);
> st.setAdapter(new NotFoundAdapter());
> st.setMaxKeepAliveRequests(0);
> SelectorThread.enableNioLogging = true;
>
> st.listen();
>
> HttpURLConnection conn = getConnection("/404.html", st.getPort());
> String s = conn.getHeaderField("Connection");
> assertEquals(s, "close");
>
> } finally {
> SelectorThreadUtils.stopSelectorThread(st);
> }
>
> }
> public class NotFoundAdapter extends GrizzlyAdapter {
>
> @Override
> public void service(GrizzlyRequest request, GrizzlyResponse response) {
> response.setStatus(404, "Not Found");
> }
> }
Can you produce a test case?
Thanks
-- Jeanfrancois
rama wrote:
> hi all,
>
> it's possible to disable keepalive on a gws?
>
> i have try
> s.getSelectorThread().setKeepAliveTimeoutInSeconds(0);
> s.getSelectorThread().setMaxKeepAliveRequests(0);
>
> but without any success :)
>
> here is a snippet
>
>
> ----------------------------------------------------
> public class ws extends GrizzlyWebServer
> {
>
> public static void main (String args[]) {
> ws s = new ws();
> s.getSelectorThread().setKeepAliveTimeoutInSeconds(0);
> s.getSelectorThread().setMaxKeepAliveRequests(0);
> s.getSelectorThread().setDisplayConfiguration(true);
> try {
> s.start();
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
> }
> ----------------------------------------------------
> wget -v -S http://localhost:8080/index.html
> --2009-11-04 21:19:30-- http://localhost:8080/index.html
> Risoluzione di localhost... 127.0.0.1, ::1, fe80::1
> Connessione a localhost|127.0.0.1|:8080... connesso.
> HTTP richiesta inviata, in attesa di risposta...
> HTTP/1.1 404 Not Found
> Content-Type: text/html
> Content-Length: 701
> Date: Wed, 04 Nov 2009 20:19:30 GMT
> Connection: Keep-Alive --> :( sigh
> 2009-11-04 21:19:30 ERRORE 404: Not Found.
I just wrote a unit test
>
>
>
> Unfortunatly i haven't find nothing on docs about that :)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: dev-help_at_grizzly.dev.java.net
>