mirror of
https://github.com/lxsang/ant-http
synced 2024-11-18 01:08:21 +01:00
fix: correct path to support fastCGI
All checks were successful
gitea-sync/ant-http/pipeline/head This commit looks good
All checks were successful
gitea-sync/ant-http/pipeline/head This commit looks good
This commit is contained in:
parent
eed2e9c1af
commit
375989acbe
@ -527,12 +527,13 @@ void *resolve_request(void *data)
|
|||||||
char path[2 * BUFFLEN];
|
char path[2 * BUFFLEN];
|
||||||
antd_request_t *rq = (antd_request_t *)data;
|
antd_request_t *rq = (antd_request_t *)data;
|
||||||
antd_task_t *task = antd_create_task(NULL, (void *)rq, NULL, rq->client->last_io);
|
antd_task_t *task = antd_create_task(NULL, (void *)rq, NULL, rq->client->last_io);
|
||||||
char *url = (char *)dvalue(rq->request, "RESOURCE_PATH");
|
char *url = (char *)dvalue(rq->request, "REQUEST_URI");
|
||||||
char *newurl = NULL;
|
char *newurl = NULL;
|
||||||
char *rqp = NULL;
|
char *rqp = NULL;
|
||||||
char *oldrqp = NULL;
|
char *oldrqp = NULL;
|
||||||
rq->client->state = ANTD_CLIENT_RESOLVE_REQUEST;
|
rq->client->state = ANTD_CLIENT_RESOLVE_REQUEST;
|
||||||
snprintf(path, sizeof(path), "%s/%s", (char *)dvalue(rq->request, "SERVER_WWW_ROOT"), url);
|
char * root = (char *)dvalue(rq->request, "SERVER_WWW_ROOT");
|
||||||
|
snprintf(path, sizeof(path), "%s/%s", root, url);
|
||||||
LOG("URL is : %s", url);
|
LOG("URL is : %s", url);
|
||||||
LOG("Resource Path is : %s", path);
|
LOG("Resource Path is : %s", path);
|
||||||
// if (path[strlen(path) - 1] == '/')
|
// if (path[strlen(path) - 1] == '/')
|
||||||
@ -548,7 +549,8 @@ void *resolve_request(void *data)
|
|||||||
rqp = strdup("/");
|
rqp = strdup("/");
|
||||||
else
|
else
|
||||||
rqp = strdup(rqp);
|
rqp = strdup(rqp);
|
||||||
dput(rq->request, "RESOURCE_PATH", rqp);
|
dput(rq->request, "REQUEST_URI", rqp);
|
||||||
|
dput(rq->request, "RESOURCE_PATH", __s("%s/%s", root,rqp));
|
||||||
LOG("Execute plugin %s", newurl);
|
LOG("Execute plugin %s", newurl);
|
||||||
task = execute_plugin(rq, newurl);
|
task = execute_plugin(rq, newurl);
|
||||||
free(oldrqp);
|
free(oldrqp);
|
||||||
@ -562,19 +564,15 @@ void *resolve_request(void *data)
|
|||||||
if (stat(path, &st) == -1)
|
if (stat(path, &st) == -1)
|
||||||
{
|
{
|
||||||
chain_t it;
|
chain_t it;
|
||||||
|
newurl = NULL;
|
||||||
for_each_assoc(it, server_config.handlers)
|
for_each_assoc(it, server_config.handlers)
|
||||||
{
|
{
|
||||||
newurl = __s("%s/index.%s", url, it->key);
|
|
||||||
memset(path, 0, sizeof(path));
|
memset(path, 0, sizeof(path));
|
||||||
snprintf(path, sizeof(path), "%s/%s", (char *)dvalue(rq->request, "SERVER_WWW_ROOT"), newurl);
|
snprintf(path, sizeof(path), "%s/%s/index.%s", root, url, it->key);
|
||||||
if (stat(path, &st) != 0)
|
if (stat(path, &st) == 0)
|
||||||
{
|
|
||||||
free(newurl);
|
|
||||||
newurl = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
i = server_config.handlers->cap;
|
i = server_config.handlers->cap;
|
||||||
|
newurl = path;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -583,12 +581,9 @@ void *resolve_request(void *data)
|
|||||||
antd_error(rq->client, 404, "Resource Not Found");
|
antd_error(rq->client, 404, "Resource Not Found");
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
// if(url) free(url); this is freed in the dput function
|
|
||||||
url = newurl;
|
|
||||||
dput(rq->request, "RESOURCE_PATH", url);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dput(rq->request, "ABS_RESOURCE_PATH", strdup(path));
|
dput(rq->request, "RESOURCE_PATH", strdup(path));
|
||||||
// check if the mime is supported
|
// check if the mime is supported
|
||||||
// if the mime is not supported
|
// if the mime is not supported
|
||||||
// find an handler plugin to process it
|
// find an handler plugin to process it
|
||||||
@ -741,7 +736,7 @@ void *serve_file(void *data)
|
|||||||
{
|
{
|
||||||
antd_request_t *rq = (antd_request_t *)data;
|
antd_request_t *rq = (antd_request_t *)data;
|
||||||
antd_task_t *task = antd_create_task(NULL, (void *)rq, NULL, rq->client->last_io);
|
antd_task_t *task = antd_create_task(NULL, (void *)rq, NULL, rq->client->last_io);
|
||||||
char *path = (char *)dvalue(rq->request, "ABS_RESOURCE_PATH");
|
char *path = (char *)dvalue(rq->request, "RESOURCE_PATH");
|
||||||
char *mime_type = (char *)dvalue(rq->request, "RESOURCE_MIME");
|
char *mime_type = (char *)dvalue(rq->request, "RESOURCE_MIME");
|
||||||
rq->client->state = ANTD_CLIENT_SERVE_FILE;
|
rq->client->state = ANTD_CLIENT_SERVE_FILE;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
@ -1236,12 +1231,14 @@ void *decode_request_header(void *data)
|
|||||||
free(query);
|
free(query);
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
LOG("REQUEST_URI:%s", buf);
|
||||||
dput(rq->request, "RESOURCE_PATH", url_decode(buf));
|
dput(rq->request, "REQUEST_URI", url_decode(buf));
|
||||||
if (query)
|
if (query)
|
||||||
{
|
{
|
||||||
decode_url_request(query, request);
|
decode_url_request(query, request);
|
||||||
free(query);
|
dput(rq->request, "REQUEST_QUERY", query);
|
||||||
|
//if(url)
|
||||||
|
// free(url);
|
||||||
}
|
}
|
||||||
// header ok, now checkmethod
|
// header ok, now checkmethod
|
||||||
task = antd_create_task(decode_request, (void *)rq, NULL, rq->client->last_io);
|
task = antd_create_task(decode_request, (void *)rq, NULL, rq->client->last_io);
|
||||||
|
Loading…
Reference in New Issue
Block a user