mirror of
https://github.com/lxsang/ant-http
synced 2025-02-28 02:32:46 +01:00
refactor code, let plugin handle application data in post request
This commit is contained in:
parent
088baa1ef5
commit
c7f6cf42cb
@ -67,12 +67,6 @@ ssl.enable=0
|
|||||||
; Sytax: [regular expression on the original request]=[new request rule]
|
; Sytax: [regular expression on the original request]=[new request rule]
|
||||||
|
|
||||||
|
|
||||||
; This enable some plugins to be initialised at server startup
|
|
||||||
[AUTOSTART]
|
|
||||||
; to start a plugin at server statup use:
|
|
||||||
;plugin = plugin_name_1
|
|
||||||
;plugin = plugin_name_2, etc
|
|
||||||
|
|
||||||
|
|
||||||
[MIMES]
|
[MIMES]
|
||||||
image/bmp=bmp
|
image/bmp=bmp
|
||||||
@ -111,3 +105,12 @@ lua = lua
|
|||||||
; php and o ther scripting languages can be
|
; php and o ther scripting languages can be
|
||||||
; handled by the cgi plugin
|
; handled by the cgi plugin
|
||||||
; php = cgi
|
; php = cgi
|
||||||
|
|
||||||
|
|
||||||
|
; This enable some plugins to be initialised at server startup
|
||||||
|
; this section shall always at the end of the
|
||||||
|
; configuration file
|
||||||
|
[AUTOSTART]
|
||||||
|
; to start a plugin at server statup use:
|
||||||
|
;plugin = plugin_name_1
|
||||||
|
;plugin = plugin_name_2, etc
|
@ -164,6 +164,7 @@ static int config_handler(void *conf, const char *section, const char *name,
|
|||||||
}
|
}
|
||||||
else if (MATCH("SERVER", "debug_enable"))
|
else if (MATCH("SERVER", "debug_enable"))
|
||||||
{
|
{
|
||||||
|
(void)setenv("ANTD_DEBUG", value, 1);
|
||||||
pconfig->debug_enable = atoi(value);
|
pconfig->debug_enable = atoi(value);
|
||||||
}
|
}
|
||||||
else if (MATCH("SERVER", "scheduler_timeout"))
|
else if (MATCH("SERVER", "scheduler_timeout"))
|
||||||
@ -812,8 +813,7 @@ static void *proxy_monitor(void *data)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( (pret > 0) && (
|
if ((pret > 0) && (pfd[0].revents & POLLERR ||
|
||||||
pfd[0].revents & POLLERR ||
|
|
||||||
pfd[0].revents & POLLRDHUP ||
|
pfd[0].revents & POLLRDHUP ||
|
||||||
pfd[0].revents & POLLHUP ||
|
pfd[0].revents & POLLHUP ||
|
||||||
pfd[0].revents & POLLNVAL))
|
pfd[0].revents & POLLNVAL))
|
||||||
@ -1226,23 +1226,8 @@ void *decode_post_request(void *data)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *pquery = post_data_decode(rq->client, clen);
|
/*let plugin hande this data as we dont known how to deal with it*/
|
||||||
char *key = strstr(ctype, "/");
|
dput(request, "HAS_RAW_BODY", strdup("true"));
|
||||||
if (key)
|
|
||||||
key++;
|
|
||||||
else
|
|
||||||
key = ctype;
|
|
||||||
if (pquery)
|
|
||||||
{
|
|
||||||
dput(request, key, pquery);
|
|
||||||
}
|
|
||||||
else if (clen > 0)
|
|
||||||
{
|
|
||||||
//task->handle = decode_post_request;
|
|
||||||
//antd_task_bind_event(task, rq->client->sock, 0, TASK_EVT_ON_READABLE | TASK_EVT_ON_WRITABLE);
|
|
||||||
antd_error(rq->client, 400, "Bad Request, missing content data");
|
|
||||||
return task;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
antd_task_bind_event(task, rq->client->sock, 0, TASK_EVT_ON_WRITABLE);
|
antd_task_bind_event(task, rq->client->sock, 0, TASK_EVT_ON_WRITABLE);
|
||||||
return task;
|
return task;
|
||||||
|
@ -296,6 +296,7 @@ void antd_send_header(void *cl, antd_response_header_t *res)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
LOG("Gzip enable on stream %d", client->sock);
|
||||||
client->z_status = Z_NO_FLUSH;
|
client->z_status = Z_NO_FLUSH;
|
||||||
dput(res->header, "Content-Encoding", strdup("gzip"));
|
dput(res->header, "Content-Encoding", strdup("gzip"));
|
||||||
}
|
}
|
||||||
@ -310,6 +311,7 @@ void antd_send_header(void *cl, antd_response_header_t *res)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
LOG("deflate enable on stream %d", client->sock);
|
||||||
client->z_status = Z_NO_FLUSH;
|
client->z_status = Z_NO_FLUSH;
|
||||||
dput(res->header, "Content-Encoding", strdup("deflate"));
|
dput(res->header, "Content-Encoding", strdup("deflate"));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user