This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LWIP & Halcogen Demo & GET

Other Parts Discussed in Thread: HALCOGEN

Dear Colleagues,

Does anybody have and example of of form submitting functionality using GET request working on LwIP on top of Halcogen Ethernet&LwIP demo? 

In httpd.h I have modified the handler definition from:

typedef char *(*tCGIHandler)(char *pcValue);

to

typedef char *(*tCGIHandler)(int iIndex, int iNumParams, char *pcParam[], char *pcValue[]);

I have populated the handler array:

static tCGI const cgi_handlers[] = { { "/index.html", &cgi_display }, };

with a primitive handler:

static char *cgi_display(int index, int numParams, char *param[], char *value[]) {
   int i;
   for (i = 0; i < numParams; ++i) {

      if (strstr(param[i], "text") != (char *)0)  /* param text found? */
         return "/thank_you.htm";
   }

   return (char *)0;
}

in lwip_main I register the handler right after httpd_init

http_set_cgi_handlers(cgi_handlers,1); //hardcoded 1 just for test

However I have doubts as to where the call has to take place. My understanding is that it should be in http_parse_request of httpd_io.c, so I wrote the following inside the parsing loop: 

if(params) {
   *params = '\0';
   params++;
   filename = g_pCGIs[i].pfnCGIHandler(i,1,&params,&data);
   break;
}

However nothing works, /index.html?text=testrequest&submit=Submit produces nothing but "No data received" in chrome.

The index.html has the following: 

<form name="CGI Example" method="GET" action="index.html">
<table summary="cgi example" width="100px" cellspacing=4 cellpadding=1 align="center" valign="middle">
<tr align="left">
<td colspan="2" bgcolor="#ffff66" align="center"><b>CGI Example</b>
</td>
</tr>
<tr bgcolor="#e0e0e0" align="left">
<td width="100px">&nbsp;&nbsp;Screen text:&nbsp;
</td>
<td>
&nbsp; <input type="text" name="text" size="10" maxlength="10">&nbsp;
<input type="submit" name="submit" value="Submit" ><br>
</td>
</tr>
</table>
</form>


Any ideas or working examples?

Anyone tried lwip 1.4.x instead of 1.3.2

Regards,

Kirill