SSI callbacks not working

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

SSI callbacks not working

ソリューションへジャンプ
2,422件の閲覧回数
seandema
Contributor IV

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

ラベル(1)
タグ(3)
0 件の賞賛
返信
1 解決策
1,910件の閲覧回数
karelm_
Contributor IV

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:

  1. Open file httpsrv_task.c in folder \rtcs\source\apps
  2. Go to line 235 (variables definitions).
  3. Add following
    1. char*  separator;
  4. Go to line 327 (case HTTPSRV_SSI_CALLBACK).
  5. Replace the code for this case with following

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

元の投稿で解決策を見る

0 件の賞賛
返信
4 返答(返信)
1,910件の閲覧回数
karelm_
Contributor IV

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

1,910件の閲覧回数
seandema
Contributor IV

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

0 件の賞賛
返信
1,911件の閲覧回数
karelm_
Contributor IV

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:

  1. Open file httpsrv_task.c in folder \rtcs\source\apps
  2. Go to line 235 (variables definitions).
  3. Add following
    1. char*  separator;
  4. Go to line 327 (case HTTPSRV_SSI_CALLBACK).
  5. Replace the code for this case with following

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

0 件の賞賛
返信
1,910件の閲覧回数
seandema
Contributor IV

That fixed it. Thank you!

0 件の賞賛
返信