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)
|
void *finish_request(void *data)
|
||||||
{
|
{
|
||||||
if (!data)
|
destroy_request(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);
|
|
||||||
server_config.connection--;
|
server_config.connection--;
|
||||||
LOG("Remaining connection %d\n", server_config.connection);
|
LOG("Remaining connection %d\n", server_config.connection);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -585,4 +585,36 @@ int read_buf(void* sock, char*buf,int size)
|
|||||||
}
|
}
|
||||||
buf[i] = '\0';
|
buf[i] = '\0';
|
||||||
return i;
|
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_send( void *source, const void* data, int len);
|
||||||
int antd_recv( void *source, void* data, int len);
|
int antd_recv( void *source, void* data, int len);
|
||||||
int antd_close(void* source);
|
int antd_close(void* source);
|
||||||
|
void destroy_request(void *data);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user