[En-Nut-Discussion] HTTP Multi Request

Dusan Ferbas dferbas at dfsoft.cz
Tue Oct 12 10:01:28 CEST 2004


Hi,

we implemented this feature with different RTOS but anyway here is an idea 
how it works. It is according to RFC, that even with http 1.0 you can use 
persistent connections. You need to know length of a stream as this is the 
only way how to distinguish between each "file". So this is not usable if 
you construct a response on the fly. Anyhow the most problematic (to debug) 
was implementation of time keeping mechanism. Because if a user stops 
transmission (close browser etc.) http server has no info about socket closure.

My idea is not to close a stream after ProcessRequest() and wait in a cycle 
for a new data or timeout (see net/tcpsock.c:NutTcpReceive() for inspiration):
         if (NutEventWait(&sock->so_rx_tq, sock->so_read_to))
             return 0;


Harald isn't there a time for having a queue for incoming TCP requests ? Do 
you have something like this Ralph (Mason) ?

Sample from a test example:

>             #define TEST_REPLY          "HTTP/1.0 200 OK\r\n" \
>                                         "Content-Length: 41\r\n\r\n" \
>                                         "<HTML><BODY><H1>Test 
> 1</H1></BODY></HTML>"
>             #define TEST_REPLY_KA       "HTTP/1.0 200 OK\r\n" \
>                                         "Connection: Keep-Alive\r\n" \
>                                         "Content-Length: 41\r\n\r\n" \
>                                         "<HTML><BODY><H1>Test 
> 1</H1></BODY></HTML>"
>             if (!ka_flg)
>             {
>                 xxx_send(sd, TEST_REPLY, sizeof(TEST_REPLY)-1, 0, &errno);
>                 return 0;
>             }
>             else
>             {
>                 xxx_send(sd, TEST_REPLY_KA, sizeof(TEST_REPLY_KA)-1, 0, 
> &errno);
>                 return 1;
>             }


At 10:34 8.10.2004, you wrote:
>Right now the http code doesn't support keepalive.
>You need to run several threads to avoid rejected
>connections. Nut/Net doesn't support a connection
>backlog either.
>
>Btw. http keepalive shouldn't be hard to implement,
>I think.
>
>Harald
>
>At 19:45 06.10.2004 +0100, you wrote:
> >As Your guys know now the http server program on NutOS only able to
> >response single Request per connection,
> >Which mean  when a browser client loading the webpage on the nutOS may
> >need a few connection(which some connection are related to the picture 
> files),
> >Web browser able operate on single connection to receive all the file.
> >
> >Anyone know how to enable this feature on our NutOS web server ?
> >
> >WF

Dusan 




More information about the En-Nut-Discussion mailing list