Spritetm / libesphttpd

NOTE: THIS CODE IS UNMAINTAINED. Please take a look at https://github.com/chmorgan/libesphttpd instead.
125 stars 109 forks source link

wifi.tpl fails after recent pull #10

Closed morganrallen closed 8 years ago

morganrallen commented 8 years ago

I'd been working with f57690ab7b866cd070b174d3c321010a15816cc0 but since pulling in the most recent changes wifi.tpl no longer renders. Of note index.tpl renders fine and increments the counter in the template as expected.

Picking apart tplWlan I see the 4 expected template tokens getting processes, and the function is hit a 5th time returning HTTPD_CGI_DONE.

The result I get is the template rendered right up until %currSsid%

...
<script type="text/javascript">

var xhr=j();
var currAp="

And the connection closes there.

morganrallen commented 8 years ago

Tracking the issue down a bit now, this makes it work.

  } else if (strcmp(token, "currSsid")==0 && strlen((char*)stconf.ssid)>0) {
    strcpy(buff, (char*)stconf.ssid);
  } else if (strcmp(token, "WiFiPasswd")==0 && strlen((char*)stconf.password)>0) {
    strcpy(buff, (char*)stconf.password);

So maybe writing the empty buff to connData is causing the problem...

Spritetm commented 8 years ago

It seems indeed that my new chunking code doesn't like zero-length buffers very much. I need to overhaul it anyway, my current implementation is needlessly inefficient.

Spritetm commented 8 years ago

Can you try a38909a ? That should fix this bug as well.

morganrallen commented 8 years ago

Nice one, looks good.

Spritetm commented 8 years ago

Cool, then I assume this is fixed :)