fix serve_file problem

This commit is contained in:
lxsang 2020-01-02 11:54:09 +01:00
parent 909d1f10e3
commit 876f60c9a2
2 changed files with 21 additions and 2 deletions

Binary file not shown.

View File

@ -539,8 +539,27 @@ void *resolve_request(void *data)
else
{
task->type = HEAVY;
//TODO empty the buff
while (read_buf(rq->client, path, sizeof(path)) > 0);;
// discard all request data
dictionary_t headers = (dictionary_t) dvalue(rq->request, "REQUEST_HEADER");
if(headers)
{
char * sclen = (char *)dvalue(headers, "Content-Length");
unsigned clen = 0;
unsigned read = 0;
int count;
if(sclen)
{
clen = atoi(sclen);
while (read < clen)
{
count = antd_recv(rq->client, path, sizeof(path) < clen ? sizeof(path): clen );
if(count <= 0)
break;
read += count;
}
}
}
task->handle = serve_file;
}
return task;