coopermaa / mongoose

Automatically exported from code.google.com/p/mongoose
MIT License
0 stars 0 forks source link

Need feature to force close a connection #382

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I feel that there should be a way for the server to force a keep-alive 
connection closed, even if the client has requested Connection: keep-alive.   
This is particularly useful if the content length is unknown.

I couldn't find any other way other than to create the following function, 
which I can then call from my embedded server:

void mg_must_close(struct mg_connection *conn)
{
    conn->must_close = 1;
}

Am I missing something obvious, or would something like the above be useful?

Original issue reported on code.google.com by bwfo...@googlemail.com on 7 Aug 2012 at 12:12

GoogleCodeExporter commented 8 years ago
Set "Connection: close" header, that should do the trick.

Original comment by valenok on 7 Aug 2012 at 8:58

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
The scenario I'm dealing with is when the client requests a keep-alive, and the 
server wishes to close the connection anyway.  I did try replying with a 
Connection: close, but mongoose remained in the connection loop despite my 
recommendation.   Setting conn->must_close to 1 did however solve my problem, 
but required code modification.

Original comment by bwfo...@googlemail.com on 15 Aug 2012 at 2:04

GoogleCodeExporter commented 8 years ago
Try sending HTTP/1.0 reply. 1.0 does not have keep-alive, and mongoose will 
forcefully close the connection.

Original comment by valenok on 15 Aug 2012 at 11:05