cancel
Showing results for 
Search instead for 
Did you mean: 

LwIP and http SSI issues.

RZasa.1
Associate III

Hi,

I am trying to get my head around LwIP stack. I am following document "Getting Started with Ethernet on the STM32 Nucleo" by Daniel W Rickey. In Server side includes (SSI) example everything works fine only when I try to access my website by entering IP of my microcontroller ("http://192.168.0.36"). When I try to access it by entering "http://192.168.0.36/index.shtml" (or any other website) page is loaded but SSIs on website are not displayed (SSIHandler is not called when apparently it should be called). I am using NUCLEO-F767ZI development board but I guess it does not matter. LwIP version 2.1.2.

Any advice appreciated.

Rafal

1 ACCEPTED SOLUTION

Accepted Solutions

Hello

In default file "/" case, tag_check evaluation made by file extension only.

For files from URIs "/file.ext" ,

in static files tag_check evaluation made from FS_FILE_FLAGS_SSI inside the file and if LWIP_HTTPD_SSI_BY_FILE_EXTENSION==1 , tag_check evaluationmade by file extension . (or)

So for dynamic files , suggest LWIP_HTTPD_SSI_BY_FILE_EXTENSION set as 1, to evaluate tag check by file extension .

View solution in original post

4 REPLIES 4

Hello

is SSI handler registered when starting HTTPD?

const char* TAGS[]={"tmp","vbat","vcc","freq","ipaddrp","ipaddrl"};

const unsigned short num_tags=sizeof(TAGS)/sizeof(const char*);

   httpd_init();

   http_set_ssi_handler(SSI_Handler, TAGS, num_tags);//set callbacks for SSI array

RZasa.1
Associate III

Hi,

Thanks for answer. Yes I got it defined :

  char const *theSSItags[2] = {"tag1","tag2"};

  httpd_init();

  http_set_ssi_handler(mySSIHandler, (char const **)theSSItags, 2);

Also I have added #define LWIP_HTTPD_SSI 1 in lwipopts.h. As I said it works when just IP is entered in the browser. I don't understand why SSIs don't not work when I enter full website address.

My SSI handler:

u16_t mySSIHandler(int iIndex, char *pcInsert, int iInsertLen)

{

//debug start

extern char GUI_buffer[200];

snprintf(GUI_buffer, sizeof(GUI_buffer), "mySSIHandler called");

HAL_UART_Transmit(&huart3, (unsigned char*)&GUI_buffer , strlen(GUI_buffer) + 1, 200);

//debug end

// see which tag in the array theSSItags to handle

if (iIndex == 0) //is “tag1�?

{

char myStr1[] = "Hello from Tag #1!"; //string to be displayed on web page

//copy the string to be displayed to pcInsert

strcpy(pcInsert, myStr1);

//return number of characters that need to be inserted in html

return strlen(myStr1);

}

else if (iIndex == 1) //is “tag2�?

{

char myStr2[] = "Hello from Tag #2!"; //string to be displayed on web page

//copy string to be displayed

strcpy(pcInsert, myStr2);

//return number of characters that need to be inserted in html

return strlen(myStr2);

}

return 0;

} //mySSIHandler

Hello

In default file "/" case, tag_check evaluation made by file extension only.

For files from URIs "/file.ext" ,

in static files tag_check evaluation made from FS_FILE_FLAGS_SSI inside the file and if LWIP_HTTPD_SSI_BY_FILE_EXTENSION==1 , tag_check evaluationmade by file extension . (or)

So for dynamic files , suggest LWIP_HTTPD_SSI_BY_FILE_EXTENSION set as 1, to evaluate tag check by file extension .

It works now!

Thank you!