mirror of
https://github.com/lxsang/ant-http
synced 2024-12-26 08:48:21 +01:00
allow plugin to close the connection at will
This commit is contained in:
parent
f79ef6232a
commit
c06e72a3e8
@ -385,29 +385,7 @@ void *resolve_request(void *data)
|
||||
|
||||
void *finish_request(void *data)
|
||||
{
|
||||
if (!data)
|
||||
return NULL;
|
||||
LOG("Close request\n");
|
||||
antd_request_t *rq = (antd_request_t *)data;
|
||||
// free all other thing
|
||||
if (rq->request)
|
||||
{
|
||||
dictionary tmp = dvalue(rq->request, "COOKIE");
|
||||
if (tmp)
|
||||
freedict(tmp);
|
||||
tmp = dvalue(rq->request, "REQUEST_HEADER");
|
||||
if (tmp)
|
||||
freedict(tmp);
|
||||
tmp = dvalue(rq->request, "REQUEST_DATA");
|
||||
if (tmp)
|
||||
freedict(tmp);
|
||||
dput(rq->request, "REQUEST_HEADER", NULL);
|
||||
dput(rq->request, "REQUEST_DATA", NULL);
|
||||
dput(rq->request, "COOKIE", NULL);
|
||||
freedict(rq->request);
|
||||
}
|
||||
antd_close(rq->client);
|
||||
free(rq);
|
||||
destroy_request(data);
|
||||
server_config.connection--;
|
||||
LOG("Remaining connection %d\n", server_config.connection);
|
||||
return NULL;
|
||||
|
@ -586,3 +586,35 @@ int read_buf(void* sock, char*buf,int size)
|
||||
buf[i] = '\0';
|
||||
return i;
|
||||
}
|
||||
/*
|
||||
We put it here since we want the plugin is able
|
||||
to destroy the request if it want to
|
||||
in this case, the plugin should return an empty
|
||||
with no data
|
||||
*/
|
||||
void destroy_request(void *data)
|
||||
{
|
||||
if (!data)
|
||||
return;
|
||||
LOG("Close request\n");
|
||||
antd_request_t *rq = (antd_request_t *)data;
|
||||
// free all other thing
|
||||
if (rq->request)
|
||||
{
|
||||
dictionary tmp = dvalue(rq->request, "COOKIE");
|
||||
if (tmp)
|
||||
freedict(tmp);
|
||||
tmp = dvalue(rq->request, "REQUEST_HEADER");
|
||||
if (tmp)
|
||||
freedict(tmp);
|
||||
tmp = dvalue(rq->request, "REQUEST_DATA");
|
||||
if (tmp)
|
||||
freedict(tmp);
|
||||
dput(rq->request, "REQUEST_HEADER", NULL);
|
||||
dput(rq->request, "REQUEST_DATA", NULL);
|
||||
dput(rq->request, "COOKIE", NULL);
|
||||
freedict(rq->request);
|
||||
}
|
||||
antd_close(rq->client);
|
||||
free(rq);
|
||||
}
|
@ -111,4 +111,5 @@ int read_buf(void* sock,char* buf,int i);
|
||||
int antd_send( void *source, const void* data, int len);
|
||||
int antd_recv( void *source, void* data, int len);
|
||||
int antd_close(void* source);
|
||||
void destroy_request(void *data);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user