1

I try to use keep-alive connection mongoose, but it seems mongoose close the connection first.

I changed the embed.c to send back the connection: keep-alive. The connection is still closed after response.

border@ubuntu:~$ nc 127.0.0.1 9999
GET /test_get_request_info HTTP/1.1
Connection: keep-alive

HTTP/1.1 200 OK
Content-Type: text/plain
Connection: keep-alive

Method: [GET]
URI: [/test_get_request_info]
HTTP version: [1/1]
HTTP header [Connection]: [keep-alive]
Query string: []
POST data: []
Remote IP: [2130706433]
Remote port: [56719]
Remote user: []          <-----------------connection closed, nc returns
border@ubuntu:~$
JohnnyHK
  • 305,182
  • 66
  • 621
  • 471
Jiang Bian
  • 1,933
  • 3
  • 16
  • 14
  • For specialised questions like this, you may be better off posting on the Mongoose support group at http://groups.google.com/group/mongoose-users/topics –  Apr 30 '09 at 08:34

1 Answers1

6

Currently it is impossible to do without changing Mongoose code. You can try to make a trick, in analyze_request() function, set the keep-alive flag:

} else if ((cb = find_callback(conn->ctx, FALSE, uri, -1)) != NULL) {
        if ((strcmp(ri->request_method, "POST") != 0 &&
            strcmp(ri->request_method, "PUT") != 0) ||
            handle_request_body(conn, -1)) {
                cb->func(conn, &conn->request_info, cb->user_data);
                conn->keep_alive = TRUE;  // ADD THIS LINE
            }

There must be better mechanism of doing this from the callback, though.

valenok
  • 827
  • 7
  • 9