I'm attempting to test the SSI callback capability of the MQX web server. I had this working under MQX 4.0 but I can't get it to work under 4.1. I'm using the same code and web page I used in 4.0 so I'm really not sure why it doesn't work.
I have created the SSI function, link table, and am passing that into the web server.
const HTTPSRV_SSI_LINK_STRUCT ssi_tbl[] = {
{ "ssiTest", ssi_test},
{ 0, 0} // DO NOT REMOVE - last item - end of table
};
static _mqx_int ssi_test(HTTPSRV_SSI_PARAM_STRUCT* param)
{
printf("SSI test func called\n");
}
HTTPSRV_PARAM_STRUCT web_srv_params;
extern const HTTPSRV_CGI_LINK_STRUCT cgi_tbl[];
extern const HTTPSRV_SSI_LINK_STRUCT ssi_tbl[];
_mem_zero(&web_srv_params, sizeof(HTTPSRV_PARAM_STRUCT));
web_srv_params.af = AF_INET;
web_srv_params.root_dir = "tfs:";
web_srv_params.index_page = "\\WebTest3.shtml";
web_srv_params.max_ses = 1;
web_srv_params.use_nagle = FALSE;
web_srv_params.script_stack = 2750;
web_srv_params.server_prio = 7;
web_srv_params.script_prio = 7;
web_srv_params.cgi_lnk_tbl = (HTTPSRV_CGI_LINK_STRUCT*) cgi_tbl;
web_srv_params.ssi_lnk_tbl = (HTTPSRV_SSI_LINK_STRUCT*) ssi_tbl;
return (HTTPSRV_init(&web_srv_params));
I have my HTML file named as a .shtml file. I have SSI calls in my HTML code in the format specified in the RTCS users guide.
<% ssiTest:parameter %>
When I load the web page it just appears to skip right over the SSI and never calls my C code function.
Does anyone have any idea why this doesn't work? It's probably something simple I'm missing since it used to work in MQX 4.0.
Thanks,
Sean
Solved! Go to Solution.
Hi,
there is a bug in MQX 4.1.0.1 preventing correct invocation of SSI with parameter. To fix it you have to do following:
char* separator;
table = (HTTPSRV_FN_LINK_STRUCT*) server->params.ssi_lnk_tbl;
/* Set separator to null character temporarily. */
separator = strchr(msg_ptr->name, ':');
if (separator != NULL)
{
*separator = '\0';
}
user_function = httpsrv_find_callback(table, msg_ptr->name, &stack_size);
if (separator != NULL)
{
*separator = ':';
}
/* Option No.1b - Run User SSI function here. */
if ((user_function != NULL) && (stack_size == 0))
{
httpsrv_call_ssi((HTTPSRV_SSI_CALLBACK_FN) user_function, msg_ptr);
httpsrv_ses_flush(msg_ptr->session);
}
break;
This should fix the problem you are experiencing.
Best regards,
Karel
Hi,
please try to apply patch MQX 4.1.0.1 and let me know if it helped you. You can find it here: MQX™ RTOS 4.1.0.1 Patch Release.
Best reagards,
Karel
I tried installing the patch but it still doesn't work.
If I set a break point in httpsrv_supp.c httpsrv_sendextstr() I can see it hitting the lines:
_msgq_send(msg_ptr);
/* Wait until SSI is processed. */
_task_block();
The check for shtml in httpsrv_sendfile() is also true when I step through
if ((0 == strcasecmp(ext, ".shtml")) || (0 == strcasecmp(ext, ".shtm")))
Though I never see httpsrv_call_ssi() being called. I'm not real familiar with this area of MQX code but it seems like that is something that should be called.
However I have noticed that if I remove the ":paramater" part of the <%function_name:parameter%> and just put <%ssiTest%> in my shtml file that it will call my SSI function. It seems to work normally in this case but I lose that ability to pass in a parameter.
If there is anything else I should try please let me know.
Thanks,
Sean
Hi,
there is a bug in MQX 4.1.0.1 preventing correct invocation of SSI with parameter. To fix it you have to do following:
char* separator;
table = (HTTPSRV_FN_LINK_STRUCT*) server->params.ssi_lnk_tbl;
/* Set separator to null character temporarily. */
separator = strchr(msg_ptr->name, ':');
if (separator != NULL)
{
*separator = '\0';
}
user_function = httpsrv_find_callback(table, msg_ptr->name, &stack_size);
if (separator != NULL)
{
*separator = ':';
}
/* Option No.1b - Run User SSI function here. */
if ((user_function != NULL) && (stack_size == 0))
{
httpsrv_call_ssi((HTTPSRV_SSI_CALLBACK_FN) user_function, msg_ptr);
httpsrv_ses_flush(msg_ptr->session);
}
break;
This should fix the problem you are experiencing.
Best regards,
Karel
That fixed it. Thank you!